2014-11-18 18:04:10 +00:00
|
|
|
/*
|
2015-05-01 16:19:44 +00:00
|
|
|
Copyright 2014 The Kubernetes Authors All rights reserved.
|
2014-11-18 18:04:10 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2015-03-26 01:52:12 +00:00
|
|
|
package cmd
|
2014-11-18 18:04:10 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
2015-08-05 22:03:47 +00:00
|
|
|
"k8s.io/kubernetes/pkg/client"
|
2014-11-18 18:04:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
|
|
|
|
func TestDescribeUnknownSchemaObject(t *testing.T) {
|
|
|
|
d := &testDescriber{Output: "test output"}
|
|
|
|
f, tf, codec := NewTestFactory()
|
|
|
|
tf.Describer = d
|
|
|
|
tf.Client = &client.FakeRESTClient{
|
|
|
|
Codec: codec,
|
|
|
|
Resp: &http.Response{StatusCode: 200, Body: objBody(codec, &internalType{Name: "foo"})},
|
|
|
|
}
|
2015-01-02 18:08:37 +00:00
|
|
|
tf.Namespace = "non-default"
|
2014-11-18 18:04:10 +00:00
|
|
|
buf := bytes.NewBuffer([]byte{})
|
|
|
|
|
2015-04-07 18:21:25 +00:00
|
|
|
cmd := NewCmdDescribe(f, buf)
|
2014-11-18 18:04:10 +00:00
|
|
|
cmd.Run(cmd, []string{"type", "foo"})
|
|
|
|
|
2015-01-02 18:08:37 +00:00
|
|
|
if d.Name != "foo" || d.Namespace != "non-default" {
|
2014-11-18 18:04:10 +00:00
|
|
|
t.Errorf("unexpected describer: %#v", d)
|
|
|
|
}
|
|
|
|
|
2015-06-12 07:08:28 +00:00
|
|
|
if buf.String() != fmt.Sprintf("%s\n\n", d.Output) {
|
2014-11-18 18:04:10 +00:00
|
|
|
t.Errorf("unexpected output: %s", buf.String())
|
|
|
|
}
|
|
|
|
}
|