mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
* fixed test Signed-off-by: David Wertenteil <dwertent@armosec.io> * update cosign-release version Signed-off-by: David Wertenteil <dwertent@armosec.io> * fixed filepath related tests Signed-off-by: David Wertenteil <dwertent@armosec.io> * failed windows tests Signed-off-by: David Wertenteil <dwertent@armosec.io> * fixed cosign version Signed-off-by: David Wertenteil <dwertent@armosec.io> * update go version Signed-off-by: David Wertenteil <dwertent@armosec.io> * fixed test Signed-off-by: David Wertenteil <dwertent@armosec.io> * change actor Signed-off-by: David Wertenteil <dwertent@armosec.io> * Cosign use secret Signed-off-by: David Wertenteil <dwertent@armosec.io> * update cosign Signed-off-by: David Wertenteil <dwertent@armosec.io> * update cosign Signed-off-by: David Wertenteil <dwertent@armosec.io> --------- Signed-off-by: David Wertenteil <dwertent@armosec.io>
64 lines
1.2 KiB
Go
64 lines
1.2 KiB
Go
package cautils
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetKustomizeDirectoryName(t *testing.T) {
|
|
type args struct {
|
|
path string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want string
|
|
createKustomization bool
|
|
}{
|
|
{
|
|
name: "kustomize directory",
|
|
args: args{
|
|
path: os.TempDir(),
|
|
},
|
|
createKustomization: true,
|
|
want: os.TempDir(),
|
|
},
|
|
{
|
|
name: "not kustomize directory",
|
|
args: args{
|
|
path: os.TempDir(),
|
|
},
|
|
createKustomization: false,
|
|
want: "",
|
|
},
|
|
{
|
|
name: "inexistent directory",
|
|
args: args{
|
|
path: filepath.Join(os.TempDir(), "bla"),
|
|
},
|
|
createKustomization: false,
|
|
want: "",
|
|
},
|
|
{
|
|
name: "empty",
|
|
args: args{
|
|
path: "",
|
|
},
|
|
want: "",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
tempFile := filepath.Join(tt.args.path, "kustomization.yaml")
|
|
if tt.createKustomization {
|
|
_ = os.WriteFile(tempFile, []byte(""), 0644)
|
|
}
|
|
if got := getKustomizeDirectoryName(tt.args.path); got != tt.want {
|
|
t.Errorf("GetKustomizeDirectoryName() = %v, want %v", got, tt.want)
|
|
}
|
|
os.Remove(tempFile)
|
|
})
|
|
}
|
|
}
|