Пример #1
0
					[]string{"Creating security group", "my-group", "my-user"},
					[]string{"OK"},
				))
			})

			It("creates the security group with those rules", func() {
				_, rules := securityGroupRepo.CreateArgsForCall(0)
				Expect(rules).To(Equal([]map[string]interface{}{
					{"protocol": "udp", "ports": "8080-9090", "destination": "198.41.191.47/1"},
				}))
			})

			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.CreateReturns(errors.New("Wops I failed"))
					})

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

				Context("when the group already exists", func() {
					BeforeEach(func() {
						securityGroupRepo.CreateReturns(errors.NewHttpError(400, "300005", "The security group is taken: my-group"))
					})