iQEcBAABCAAGBQJYfoobAAoJED0WkGtPHFyz80gH/RNPz9wEQ9kjzmq5Zccmxcnn
Nz8+i0Ksr4dvwTV7SaYO8NHpkqTR6z5X1vLlwIAve/hjCyvZ58xT1qEbPyXNWXvq sYgj1b490wdrF0cFQVY7YoKUK5FgwGnmdK+vXG2bUZl6qlnik742QDP5zkxPnwHI tpz4o0SfOisxFFkktowems4SMBBLSozqChzAnhbE0b5L/+bLcxOkNaZ8w0CPX5TE 1uVpw+lAuLq/10XKBhWb6wyc/2+aW0EfUs/4JIK69giPY+Km0QMejIJ4UYc6ml2F DOGcWR+nKbeMIi6TFMZd1MdfLhSzipRxCECv1MYEZgIg3nGchYdybriJiYG8R3M= =DxiX -----END PGP SIGNATURE----- Correct import statements
This commit is contained in:
parent
474b80883a
commit
e31581569e
|
@ -21,59 +21,9 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
type nameGeneratorFunc func(base string) string
|
||||
|
||||
func (fn nameGeneratorFunc) GenerateName(base string) string {
|
||||
return fn(base)
|
||||
}
|
||||
|
||||
func TestGenerateName(t *testing.T) {
|
||||
testCases := []struct {
|
||||
meta ObjectMeta
|
||||
|
||||
base string
|
||||
returned string
|
||||
}{
|
||||
{
|
||||
returned: "",
|
||||
},
|
||||
{
|
||||
meta: ObjectMeta{
|
||||
GenerateName: "test",
|
||||
},
|
||||
base: "test",
|
||||
returned: "test",
|
||||
},
|
||||
{
|
||||
meta: ObjectMeta{
|
||||
Name: "foo",
|
||||
GenerateName: "test",
|
||||
},
|
||||
base: "test",
|
||||
returned: "foo",
|
||||
},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
GenerateName(nameGeneratorFunc(func(base string) string {
|
||||
if base != testCase.base {
|
||||
t.Errorf("%d: unexpected call with base", i)
|
||||
}
|
||||
return "test"
|
||||
}), &testCase.meta)
|
||||
expect := testCase.returned
|
||||
if expect != testCase.meta.Name {
|
||||
t.Errorf("%d: unexpected name: %#v", i, testCase.meta)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSimpleNameGenerator(t *testing.T) {
|
||||
meta := &metav1.ObjectMeta{
|
||||
GenerateName: "foo",
|
||||
}
|
||||
metav1.GenerateName(SimpleNameGenerator, meta)
|
||||
if !strings.HasPrefix(meta.Name, "foo") || meta.Name == "foo" {
|
||||
t.Errorf("unexpected name: %#v", meta)
|
||||
name := SimpleNameGenerator.GenerateName("foo")
|
||||
if !strings.HasPrefix(name, "foo") || name == "foo" {
|
||||
t.Errorf("unexpected name: %s", name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
apierrors "k8s.io/client-go/pkg/api/errors"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
|
||||
|
|
Loading…
Reference in New Issue