providers/aws: fixing faililng test
This commit is contained in:
parent
61811fce23
commit
81913c58fb
|
@ -5,6 +5,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/flatmap"
|
"github.com/hashicorp/terraform/flatmap"
|
||||||
|
"github.com/hashicorp/terraform/helper/hashcode"
|
||||||
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/mitchellh/goamz/ec2"
|
"github.com/mitchellh/goamz/ec2"
|
||||||
"github.com/mitchellh/goamz/elb"
|
"github.com/mitchellh/goamz/elb"
|
||||||
)
|
)
|
||||||
|
@ -33,16 +35,20 @@ func testConf() map[string]string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_expandIPPerms(t *testing.T) {
|
func Test_expandIPPerms(t *testing.T) {
|
||||||
|
hash := func(v interface{}) int {
|
||||||
|
return hashcode.String(v.(string))
|
||||||
|
}
|
||||||
|
|
||||||
expanded := []interface{}{
|
expanded := []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"protocol": "icmp",
|
"protocol": "icmp",
|
||||||
"from_port": 1,
|
"from_port": 1,
|
||||||
"to_port": -1,
|
"to_port": -1,
|
||||||
"cidr_blocks": []interface{}{"0.0.0.0/0"},
|
"cidr_blocks": []interface{}{"0.0.0.0/0"},
|
||||||
"security_groups": []interface{}{
|
"security_groups": schema.NewSet(hash, []interface{}{
|
||||||
"sg-11111",
|
"sg-11111",
|
||||||
"foo/sg-22222",
|
"foo/sg-22222",
|
||||||
},
|
}),
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"protocol": "icmp",
|
"protocol": "icmp",
|
||||||
|
@ -60,13 +66,13 @@ func Test_expandIPPerms(t *testing.T) {
|
||||||
ToPort: -1,
|
ToPort: -1,
|
||||||
SourceIPs: []string{"0.0.0.0/0"},
|
SourceIPs: []string{"0.0.0.0/0"},
|
||||||
SourceGroups: []ec2.UserSecurityGroup{
|
SourceGroups: []ec2.UserSecurityGroup{
|
||||||
ec2.UserSecurityGroup{
|
|
||||||
Id: "sg-11111",
|
|
||||||
},
|
|
||||||
ec2.UserSecurityGroup{
|
ec2.UserSecurityGroup{
|
||||||
OwnerId: "foo",
|
OwnerId: "foo",
|
||||||
Id: "sg-22222",
|
Id: "sg-22222",
|
||||||
},
|
},
|
||||||
|
ec2.UserSecurityGroup{
|
||||||
|
Id: "sg-11111",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ec2.IPPerm{
|
ec2.IPPerm{
|
||||||
|
|
|
@ -14,6 +14,17 @@ type Set struct {
|
||||||
once sync.Once
|
once sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewSet is a convenience method for creating a new set with the given
|
||||||
|
// items.
|
||||||
|
func NewSet(f SchemaSetFunc, items []interface{}) *Set {
|
||||||
|
s := &Set{F: f}
|
||||||
|
for _, i := range items {
|
||||||
|
s.Add(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
// Add adds an item to the set if it isn't already in the set.
|
// Add adds an item to the set if it isn't already in the set.
|
||||||
func (s *Set) Add(item interface{}) {
|
func (s *Set) Add(item interface{}) {
|
||||||
s.add(item)
|
s.add(item)
|
||||||
|
|
Loading…
Reference in New Issue