当前位置: 首页>>代码示例>>Golang>>正文


Golang FakeSecurityGroupRepo.ReadReturns方法代码示例

本文整理汇总了Golang中code/cloudfoundry/org/cli/cf/api/securitygroups/securitygroupsfakes.FakeSecurityGroupRepo.ReadReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeSecurityGroupRepo.ReadReturns方法的具体用法?Golang FakeSecurityGroupRepo.ReadReturns怎么用?Golang FakeSecurityGroupRepo.ReadReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在code/cloudfoundry/org/cli/cf/api/securitygroups/securitygroupsfakes.FakeSecurityGroupRepo的用法示例。


在下文中一共展示了FakeSecurityGroupRepo.ReadReturns方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

					requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})

					Expect(runCommand("my-craaaaaazy-security-group", "my-org")).To(BeTrue())
				})
			})
		})
	})

	Context("when the user is logged in and provides the name of a security group", func() {
		BeforeEach(func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
		})

		Context("when a security group with that name does not exist", func() {
			BeforeEach(func() {
				fakeSecurityGroupRepo.ReadReturns(models.SecurityGroup{}, errors.NewModelNotFoundError("security group", "my-nonexistent-security-group"))
			})

			It("fails and tells the user", func() {
				runCommand("my-nonexistent-security-group", "my-org", "my-space")

				Expect(fakeSecurityGroupRepo.ReadArgsForCall(0)).To(Equal("my-nonexistent-security-group"))
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"FAILED"},
					[]string{"security group", "my-nonexistent-security-group", "not found"},
				))
			})
		})

		Context("when the org does not exist", func() {
			BeforeEach(func() {
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:bind_security_group_test.go

示例2:

	Context("when logged in", func() {
		BeforeEach(func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
		})

		Context("when everything exists", func() {
			BeforeEach(func() {
				securityGroup := models.SecurityGroup{
					SecurityGroupFields: models.SecurityGroupFields{
						Name:  "my-group",
						GUID:  "my-group-guid",
						Rules: []map[string]interface{}{},
					},
				}

				securityGroupRepo.ReadReturns(securityGroup, nil)

				orgRepo.ListOrgsReturns([]models.Organization{{
					OrganizationFields: models.OrganizationFields{
						Name: "my-org",
						GUID: "my-org-guid",
					}},
				}, nil)

				space := models.Space{SpaceFields: models.SpaceFields{Name: "my-space", GUID: "my-space-guid"}}
				spaceRepo.FindByNameInOrgReturns(space, nil)
			})

			It("removes the security group when we only pass the security group name (using the targeted org and space)", func() {
				runCommand("my-group")
开发者ID:fujitsu-cf,项目名称:cli,代码行数:30,代码来源:unbind_security_group_test.go

示例3:

			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"Incorrect Usage", "Requires", "argument"},
			))
		})
	})

	Context("when logged in", func() {
		BeforeEach(func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
		})

		Context("when the group with the given name exists", func() {
			BeforeEach(func() {
				securityGroupRepo.ReadReturns(models.SecurityGroup{
					SecurityGroupFields: models.SecurityGroupFields{
						Name: "my-group",
						GUID: "group-guid",
					},
				}, nil)
			})

			Context("delete a security group", func() {
				It("when passed the -f flag", func() {
					runCommand("-f", "my-group")
					Expect(securityGroupRepo.ReadArgsForCall(0)).To(Equal("my-group"))
					Expect(securityGroupRepo.DeleteArgsForCall(0)).To(Equal("group-guid"))

					Expect(ui.Prompts).To(BeEmpty())
				})

				It("should prompt user when -f flag is not present", func() {
					ui.Inputs = []string{"y"}
开发者ID:fujitsu-cf,项目名称:cli,代码行数:32,代码来源:delete_security_group_test.go

示例4:

				[]string{"Incorrect Usage", "Requires", "arguments"},
			))
		})
	})

	Context("when the user is logged in", func() {
		var tempFile *os.File
		BeforeEach(func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			securityGroup := models.SecurityGroup{
				SecurityGroupFields: models.SecurityGroupFields{
					Name: "my-group-name",
					GUID: "my-group-guid",
				},
			}
			securityGroupRepo.ReadReturns(securityGroup, nil)
			tempFile, _ = ioutil.TempFile("", "")
		})

		AfterEach(func() {
			tempFile.Close()
			os.Remove(tempFile.Name())
		})

		JustBeforeEach(func() {
			runCommand("my-group-name", tempFile.Name())
		})

		Context("when the file specified has valid json", func() {
			BeforeEach(func() {
				tempFile.Write([]byte(`[{"protocol":"udp","port":"8080-9090","destination":"198.41.191.47/1"}]`))
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:update_security_group_test.go

示例5:

		It("fails with usage when a name is not provided", func() {
			runCommand()
			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"Incorrect Usage", "Requires", "argument"},
			))
		})
	})

	Context("when the user is logged in and provides the name of a group", func() {
		BeforeEach(func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			group := models.SecurityGroup{}
			group.GUID = "being-a-guid"
			group.Name = "security-group-name"
			fakeSecurityGroupRepo.ReadReturns(group, nil)
		})

		JustBeforeEach(func() {
			runCommand("security-group-name")
		})

		It("Describes what it is doing to the user", func() {
			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"Binding", "security-group-name", "as", "my-user"},
				[]string{"OK"},
				[]string{"TIP: Changes will not apply to existing running applications until they are restarted."},
			))
		})

		It("binds the group to the running group set", func() {
开发者ID:fujitsu-cf,项目名称:cli,代码行数:30,代码来源:bind_running_security_group_test.go

示例6:

				[]string{"Incorrect Usage", "Requires", "argument"},
			))
		})
	})

	Context("when the user is logged in and provides the name of a group", func() {
		BeforeEach(func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
		})

		Context("security group exists", func() {
			BeforeEach(func() {
				group := models.SecurityGroup{}
				group.GUID = "just-pretend-this-is-a-guid"
				group.Name = "a-security-group-name"
				fakeSecurityGroupRepo.ReadReturns(group, nil)
			})

			JustBeforeEach(func() {
				runCommand("a-security-group-name")
			})

			It("unbinds the group from the default staging group set", func() {
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"Unbinding", "security group", "a-security-group-name", "my-user"},
					[]string{"OK"},
				))

				Expect(fakeSecurityGroupRepo.ReadArgsForCall(0)).To(Equal("a-security-group-name"))
				Expect(fakeStagingSecurityGroupsRepo.UnbindFromStagingSetArgsForCall(0)).To(Equal("just-pretend-this-is-a-guid"))
			})
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:unbind_staging_security_group_test.go

示例7:

						GUID:  "group-guid",
						Rules: rulesMap,
					},
					Spaces: []models.Space{
						{
							SpaceFields:  models.SpaceFields{GUID: "my-space-guid-1", Name: "space-1"},
							Organization: models.OrganizationFields{GUID: "my-org-guid-1", Name: "org-1"},
						},
						{
							SpaceFields:  models.SpaceFields{GUID: "my-space-guid", Name: "space-2"},
							Organization: models.OrganizationFields{GUID: "my-org-guid-1", Name: "org-2"},
						},
					},
				}

				securityGroupRepo.ReadReturns(securityGroup, nil)
			})

			It("should fetch the security group from its repo", func() {
				runCommand("my-group")
				Expect(securityGroupRepo.ReadArgsForCall(0)).To(Equal("my-group"))
			})

			It("tells the user what it's about to do and then shows the group", func() {
				runCommand("my-group")
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"Getting", "security group", "my-group", "my-user"},
					[]string{"OK"},
					[]string{"Name", "my-group"},
					[]string{"Rules"},
					[]string{"["},
开发者ID:fujitsu-cf,项目名称:cli,代码行数:31,代码来源:security_group_test.go


注:本文中的code/cloudfoundry/org/cli/cf/api/securitygroups/securitygroupsfakes.FakeSecurityGroupRepo.ReadReturns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。