general cleanup - addressing code review
This commit is contained in:
parent
498ffbf77b
commit
b979053361
|
@ -264,10 +264,6 @@ var DistinctFunc = function.New(&function.Spec{
|
|||
},
|
||||
Type: function.StaticReturnType(cty.List(cty.DynamicPseudoType)),
|
||||
Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) {
|
||||
if len(args) != 1 {
|
||||
return cty.NilVal, fmt.Errorf("distinct accepts only one argument")
|
||||
}
|
||||
|
||||
var list []cty.Value
|
||||
|
||||
for it := args[0].ElementIterator(); it.Next(); {
|
||||
|
@ -295,7 +291,9 @@ var ChunklistFunc = function.New(&function.Spec{
|
|||
Type: cty.Number,
|
||||
},
|
||||
},
|
||||
Type: function.StaticReturnType(cty.List(cty.DynamicPseudoType)),
|
||||
Type: func(args []cty.Value) (cty.Type, error) {
|
||||
return cty.List(args[0].Type()), nil
|
||||
},
|
||||
Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) {
|
||||
var size int
|
||||
err = gocty.FromCtyValue(args[1], &size)
|
||||
|
|
|
@ -459,6 +459,17 @@ func TestContains(t *testing.T) {
|
|||
cty.BoolVal(false),
|
||||
false,
|
||||
},
|
||||
{ // Check a list with an unknown value
|
||||
cty.ListVal([]cty.Value{
|
||||
cty.UnknownVal(cty.String),
|
||||
cty.StringVal("quick"),
|
||||
cty.StringVal("brown"),
|
||||
cty.StringVal("fox"),
|
||||
}),
|
||||
cty.StringVal("quick"),
|
||||
cty.BoolVal(true),
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
@ -474,7 +485,7 @@ func TestContains(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
|
||||
if got != test.Want {
|
||||
if !got.RawEquals(test.Want) {
|
||||
t.Errorf("wrong result\ngot: %#v\nwant: %#v", got, test.Want)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue