本文整理汇总了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)
}
示例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)
}
示例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"))
}
示例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)
}
示例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)
}
示例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)
}