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


Golang EC2er.On方法代码示例

本文整理汇总了Golang中github.com/amanya/addsg/mocks.EC2er.On方法的典型用法代码示例。如果您正苦于以下问题:Golang EC2er.On方法的具体用法?Golang EC2er.On怎么用?Golang EC2er.On使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/amanya/addsg/mocks.EC2er的用法示例。


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

示例1: TestAddIpToSecurityGroup

func (s *AddSGSuite) TestAddIpToSecurityGroup() {
	client := new(mocks.EC2er)
	client.On("AuthorizeSecurityGroupIngress", mock.AnythingOfType("*ec2.AuthorizeSecurityGroupIngressInput")).Return(nil, nil)

	helper := &EC2Helper{client}

	err := helper.addIpToSecurityGroup("1.2.3.4/32", "sg-asdf")
	s.Equal(err, nil)
}
开发者ID:amanya,项目名称:addsg,代码行数:9,代码来源:addsg_test.go

示例2: TestGetSecurityGroupNotExists

func (s *AddSGSuite) TestGetSecurityGroupNotExists() {
	client := new(mocks.EC2er)
	client.On("DescribeSecurityGroups", mock.AnythingOfType("*ec2.DescribeSecurityGroupsInput")).Return(&ec2.DescribeSecurityGroupsOutput{}, nil)

	helper := &EC2Helper{client}

	sg, err := helper.getSecurityGroup("asdf", "zxcv")
	s.Equal(sg, "")
	s.Equal(err, nil)
}
开发者ID:amanya,项目名称:addsg,代码行数:10,代码来源:addsg_test.go

示例3: TestGetInstanceNotFound

func (s *AddSGSuite) TestGetInstanceNotFound() {
	client := new(mocks.EC2er)
	client.On("DescribeInstances", mock.AnythingOfType("*ec2.DescribeInstancesInput")).Return(
		&ec2.DescribeInstancesOutput{
			Reservations: []*ec2.Reservation{},
		}, nil)

	helper := &EC2Helper{client}

	i, err := helper.getInstance("1.1.1.1")
	assert.Nil(s.T(), i)
	s.Equal(err, fmt.Errorf("instance not found"))
}
开发者ID:amanya,项目名称:addsg,代码行数:13,代码来源:addsg_test.go

示例4: TestCreateSecurityGroup

func (s *AddSGSuite) TestCreateSecurityGroup() {
	client := new(mocks.EC2er)
	client.On("CreateSecurityGroup", mock.AnythingOfType("*ec2.CreateSecurityGroupInput")).Return(
		&ec2.CreateSecurityGroupOutput{
			GroupId: aws.String("sg-asdf"),
		}, nil)

	helper := &EC2Helper{client}

	sg, err := helper.createSecurityGroup("vpc-asdf", "asdf")

	s.Equal(sg, "sg-asdf")
	s.Equal(err, nil)
}
开发者ID:amanya,项目名称:addsg,代码行数:14,代码来源:addsg_test.go

示例5: TestAddSecurityGroupToInstance

func (s *AddSGSuite) TestAddSecurityGroupToInstance() {
	client := new(mocks.EC2er)

	i := &ec2.Instance{
		InstanceId: aws.String("i-asdf"),
		SecurityGroups: []*ec2.GroupIdentifier{
			&ec2.GroupIdentifier{
				GroupId: aws.String("sg-asdf"),
			},
		},
	}

	client.On("ModifyInstanceAttribute", mock.AnythingOfType("*ec2.ModifyInstanceAttributeInput")).Return(nil, nil)

	helper := &EC2Helper{client}

	err := helper.addSecurityGroupToInstance(i, "sg-qwer")
	s.Equal(err, nil)
}
开发者ID:amanya,项目名称:addsg,代码行数:19,代码来源:addsg_test.go

示例6: TestGetInstanceFound

func (s *AddSGSuite) TestGetInstanceFound() {
	client := new(mocks.EC2er)
	client.On("DescribeInstances", mock.AnythingOfType("*ec2.DescribeInstancesInput")).Return(
		&ec2.DescribeInstancesOutput{
			Reservations: []*ec2.Reservation{
				&ec2.Reservation{
					Instances: []*ec2.Instance{
						&ec2.Instance{
							InstanceId: aws.String("i-asdfasdf"),
						},
					},
				},
			},
		}, nil)

	helper := &EC2Helper{client}

	i, err := helper.getInstance("1.1.1.1")
	s.Equal(i.InstanceId, aws.String("i-asdfasdf"))
	s.Equal(err, nil)
}
开发者ID:amanya,项目名称:addsg,代码行数:21,代码来源:addsg_test.go


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