Move the common test functions from cmd_test.go to cmd/testing/fake.go

This is so that we can use NewAPIFactory() from cmd/set/*test.go
Up until now we would get a import loop error.

This commit also adds a basic unit test case for cmd/set/set_image.go
This commit is contained in:
Angus Salkeld
2016-10-19 08:53:26 +10:00
parent 4b7024efe7
commit d58554a647
32 changed files with 753 additions and 614 deletions

View File

@@ -33,6 +33,7 @@ import (
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/unversioned/fake"
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
"k8s.io/kubernetes/pkg/util/term"
)
@@ -126,7 +127,7 @@ func TestPodAndContainer(t *testing.T) {
},
}
for _, test := range tests {
f, tf, _, ns := NewAPIFactory()
f, tf, _, ns := cmdtesting.NewAPIFactory()
tf.Client = &fake.RESTClient{
NegotiatedSerializer: ns,
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { return nil, nil }),
@@ -180,7 +181,7 @@ func TestExec(t *testing.T) {
},
}
for _, test := range tests {
f, tf, codec, ns := NewAPIFactory()
f, tf, codec, ns := cmdtesting.NewAPIFactory()
tf.Client = &fake.RESTClient{
NegotiatedSerializer: ns,
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {