Add tests for filterTags function.

This commit is contained in:
Andrew Starr-Bochicchio 2019-07-03 12:30:49 -04:00
parent 51961debcc
commit 08c7646403
1 changed files with 32 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package digitalocean
import (
"context"
"fmt"
"reflect"
"testing"
"github.com/digitalocean/godo"
@ -336,3 +337,34 @@ func testAccCheckDigitalOceanKubernetesClusterExists(n string, cluster *godo.Kub
return nil
}
}
func Test_filterTags(t *testing.T) {
tests := []struct {
have []string
want []string
}{
{
have: []string{"k8s", "foo"},
want: []string{"foo"},
},
{
have: []string{"k8s", "k8s:looks-like-a-uuid", "bar"},
want: []string{"bar"},
},
{
have: []string{"k8s", "k8s:looks-like-a-uuid", "bar", "k8s-this-is-ok"},
want: []string{"bar", "k8s-this-is-ok"},
},
{
have: []string{"k8s", "k8s:looks-like-a-uuid", "terraform:default-node-pool", "baz"},
want: []string{"baz"},
},
}
for _, tt := range tests {
filteredTags := filterTags(tt.have)
if !reflect.DeepEqual(filteredTags, tt.want) {
t.Errorf("filterTags returned %+v, expected %+v", filteredTags, tt.want)
}
}
}