Skip to content

Commit

Permalink
Add unit tests for Manifest.IsConfigMap method
Browse files Browse the repository at this point in the history
Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
  • Loading branch information
Warashi committed Dec 25, 2024
1 parent 6f2bb43 commit 3659381
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions pkg/app/pipedv1/plugin/kubernetes/provider/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,3 +668,58 @@ data:
})
}
}

func TestManifest_IsConfigMap(t *testing.T) {
tests := []struct {
name string
manifest string
want bool
}{
{
name: "is configmap",
manifest: `
apiVersion: v1
kind: ConfigMap
metadata:
name: my-config
namespace: default
data:
key: value
`,
want: true,
},
{
name: "is not configmap",
manifest: `
apiVersion: v1
kind: Secret
metadata:
name: my-secret
namespace: default
data:
key: dmFsdWU=
`,
want: false,
},
{
name: "is not configmap with custom apigroup",
manifest: `
apiVersion: custom.io/v1
kind: ConfigMap
metadata:
name: custom-config
data:
key: value
`,
want: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
manifest := mustParseManifests(t, strings.TrimSpace(tt.manifest))[0]
got := manifest.IsConfigMap()
assert.Equal(t, tt.want, got)
})
}
}

0 comments on commit 3659381

Please sign in to comment.