mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 16:06:56 +00:00
38 lines
870 B
Go
38 lines
870 B
Go
package policy
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/go-git/go-billy/v5"
|
|
)
|
|
|
|
func TestLoad(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
fs billy.Filesystem
|
|
resourcePath string
|
|
paths []string
|
|
wantErr bool
|
|
}{{
|
|
name: "cpol-limit-configmap-for-sa",
|
|
fs: nil,
|
|
resourcePath: "",
|
|
paths: []string{"../_testdata/policies/cpol-limit-configmap-for-sa.yaml"},
|
|
wantErr: false,
|
|
}, {
|
|
name: "invalid-schema",
|
|
fs: nil,
|
|
resourcePath: "",
|
|
paths: []string{"../_testdata/policies/invalid-schema.yaml"},
|
|
wantErr: true,
|
|
}}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
_, _, err := Load(tt.fs, tt.resourcePath, tt.paths...)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("Load() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
})
|
|
}
|
|
}
|