Add local option to the label command

This is to be used with the new "set selector" command.
This commit is contained in:
Angus Salkeld
2016-10-05 15:45:27 +10:00
parent 092b2cc081
commit 5cb945d672
3 changed files with 47 additions and 5 deletions

View File

@@ -383,6 +383,34 @@ func TestLabelForResourceFromFile(t *testing.T) {
}
}
func TestLabelLocal(t *testing.T) {
f, tf, _, ns := NewAPIFactory()
tf.Client = &fake.RESTClient{
NegotiatedSerializer: ns,
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
t.Fatalf("unexpected request: %s %#v\n%#v", req.Method, req.URL, req)
return nil, nil
}),
}
tf.Namespace = "test"
tf.ClientConfig = &restclient.Config{ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}
buf := bytes.NewBuffer([]byte{})
cmd := NewCmdLabel(f, buf)
cmd.Flags().Set("local", "true")
options := &resource.FilenameOptions{
Filenames: []string{"../../../examples/storage/cassandra/cassandra-controller.yaml"},
}
err := RunLabel(f, buf, cmd, []string{"a=b"}, options)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !strings.Contains(buf.String(), "labeled") {
t.Errorf("did not set labels: %s", buf.String())
}
}
func TestLabelMultipleObjects(t *testing.T) {
pods, _, _ := testData()
f, tf, codec, ns := NewAPIFactory()