don't forget to test the simple things
This commit is contained in:
parent
b45b6a5c20
commit
bd983f6cba
|
@ -1,6 +1,8 @@
|
|||
package terraform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
@ -96,3 +98,44 @@ func TestUtilResourceProvider(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUniqueStrings(t *testing.T) {
|
||||
cases := []struct {
|
||||
Input []string
|
||||
Expected []string
|
||||
}{
|
||||
{
|
||||
[]string{},
|
||||
[]string{},
|
||||
},
|
||||
{
|
||||
[]string{"x"},
|
||||
[]string{"x"},
|
||||
},
|
||||
{
|
||||
[]string{"a", "b", "c"},
|
||||
[]string{"a", "b", "c"},
|
||||
},
|
||||
{
|
||||
[]string{"a", "a", "a"},
|
||||
[]string{"a"},
|
||||
},
|
||||
{
|
||||
[]string{"a", "b", "a", "b", "a", "a"},
|
||||
[]string{"a", "b"},
|
||||
},
|
||||
{
|
||||
[]string{"c", "b", "a", "c", "b"},
|
||||
[]string{"a", "b", "c"},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
t.Run(fmt.Sprintf("unique-%d", i), func(t *testing.T) {
|
||||
actual := uniqueStrings(tc.Input)
|
||||
if !reflect.DeepEqual(tc.Expected, actual) {
|
||||
t.Fatalf("Expected: %q\nGot: %q", tc.Expected, actual)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue