github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/kubernetes/structures_test.go (about)

     1  package kubernetes
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestIsInternalAnnotationKey(t *testing.T) {
     9  	testCases := []struct {
    10  		Key      string
    11  		Expected bool
    12  	}{
    13  		{"", false},
    14  		{"anyKey", false},
    15  		{"any.hostname.io", false},
    16  		{"any.hostname.com/with/path", false},
    17  		{"any.kubernetes.io", true},
    18  		{"kubernetes.io", true},
    19  		{"pv.kubernetes.io/any/path", true},
    20  	}
    21  	for i, tc := range testCases {
    22  		t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
    23  			isInternal := isInternalAnnotationKey(tc.Key)
    24  			if tc.Expected && isInternal != tc.Expected {
    25  				t.Fatalf("Expected %q to be internal", tc.Key)
    26  			}
    27  			if !tc.Expected && isInternal != tc.Expected {
    28  				t.Fatalf("Expected %q not to be internal", tc.Key)
    29  			}
    30  		})
    31  	}
    32  }