mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
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:
@@ -26,6 +26,7 @@ import (
|
||||
"k8s.io/heapster/metrics/apis/metrics/v1alpha1"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/client/unversioned/fake"
|
||||
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
@@ -40,7 +41,7 @@ func TestTopNodeAllMetrics(t *testing.T) {
|
||||
expectedMetricsPath := fmt.Sprintf("%s/%s/nodes", baseMetricsAddress, metricsApiVersion)
|
||||
expectedNodePath := fmt.Sprintf("/%s/%s/nodes", apiPrefix, apiVersion)
|
||||
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
f, tf, codec, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
NegotiatedSerializer: ns,
|
||||
@@ -88,7 +89,7 @@ func TestTopNodeWithNameMetrics(t *testing.T) {
|
||||
expectedPath := fmt.Sprintf("%s/%s/nodes/%s", baseMetricsAddress, metricsApiVersion, expectedMetrics.Name)
|
||||
expectedNodePath := fmt.Sprintf("/%s/%s/nodes/%s", apiPrefix, apiVersion, expectedMetrics.Name)
|
||||
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
f, tf, codec, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
NegotiatedSerializer: ns,
|
||||
@@ -147,7 +148,7 @@ func TestTopNodeWithLabelSelectorMetrics(t *testing.T) {
|
||||
expectedQuery := fmt.Sprintf("labelSelector=%s", url.QueryEscape(label))
|
||||
expectedNodePath := fmt.Sprintf("/%s/%s/nodes", apiPrefix, apiVersion)
|
||||
|
||||
f, tf, codec, ns := NewAPIFactory()
|
||||
f, tf, codec, ns := cmdtesting.NewAPIFactory()
|
||||
tf.Printer = &testPrinter{}
|
||||
tf.Client = &fake.RESTClient{
|
||||
NegotiatedSerializer: ns,
|
||||
|
||||
Reference in New Issue
Block a user