diff --git a/api/k8sdeps/kunstruct/hasher_test.go b/api/k8sdeps/kunstruct/hasher_test.go new file mode 100644 index 000000000..02953f970 --- /dev/null +++ b/api/k8sdeps/kunstruct/hasher_test.go @@ -0,0 +1,34 @@ +package kunstruct + +import ( + "testing" +) + +func TestHasher(t *testing.T) { + input := ` +apiVersion: v1 +kind: ConfigMap +metadata: + name: foo +data: + one: "" +binaryData: + two: "" +` + expect := "698h7c7t9m" + + factory := NewKunstructuredFactoryImpl() + k, err := factory.SliceFromBytes([]byte(input)) + if err != nil { + t.Fatal(err) + } + + hasher := NewKustHash() + result, err := hasher.Hash(k[0]) + if err != nil { + t.Fatal(err) + } + if result != expect { + t.Fatalf("expect %s but got %s", expect, result) + } +}