Skip to content

Instantly share code, notes, and snippets.

@ethanfrogers
Created March 5, 2018 23:35
Show Gist options
  • Save ethanfrogers/c575d24156d616cd6008822f9198d918 to your computer and use it in GitHub Desktop.
Save ethanfrogers/c575d24156d616cd6008822f9198d918 to your computer and use it in GitHub Desktop.
Kubernets Client GO Test
package namespaces
import (
"testing"
"k8s.io/apimachinery/pkg/apis/meta/v1"
testclient "k8s.io/client-go/kubernetes/fake"
)
func TestNewNamespaceWithSuffix(t *testing.T) {
cases := []struct {
ns string
}{
{
ns: "test",
},
}
api := &KubernetesAPI{
Suffix: "unit-test",
Client: testclient.NewSimpleClientset(),
}
for _, c := range cases {
// create the postfixed namespace
err := api.NewNamespaceWithSuffix(c.ns)
if err != nil {
t.Fatal(err.Error())
}
_, err = api.Client.CoreV1().Namespaces().Get("test-unit-test", v1.GetOptions{})
if err != nil {
t.Fatal(err.Error())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment