Пример #1
0
			})

			It("displays a message describing what its going to do", func() {
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Updating security group", "my-group-name", "my-user"},
					[]string{"OK"},
					[]string{"TIP: Changes will not apply to existing running applications until they are restarted."},
				))
			})

			It("updates the security group with those rules, obviously", func() {
				jsonData := []map[string]interface{}{
					{"protocol": "udp", "port": "8080-9090", "destination": "198.41.191.47/1"},
				}

				_, jsonArg := securityGroupRepo.UpdateArgsForCall(0)

				Expect(jsonArg).To(Equal(jsonData))
			})

			Context("when the API returns an error", func() {
				Context("some sort of awful terrible error that we were not prescient enough to anticipate", func() {
					BeforeEach(func() {
						securityGroupRepo.UpdateReturns(errors.New("Wops I failed"))
					})

					It("fails loudly", func() {
						Expect(ui.Outputs).To(ContainSubstrings(
							[]string{"Updating security group", "my-group-name"},
							[]string{"FAILED"},
						))