// Verify that resource.RESTClients constructed from a factory respect mapping.APIVersion
func TestClientVersions(t *testing.T) {
	f := cmdutil.NewFactory(nil)

	version := testapi.Version()
	mapping := &meta.RESTMapping{
		APIVersion: version,
	}
	c, err := f.RESTClient(mapping)
	if err != nil {
		t.Errorf("unexpected error: %v", err)
	}
	client := c.(*client.RESTClient)
	if client.APIVersion() != version {
		t.Errorf("unexpected Client APIVersion: %s %v", client.APIVersion, client)
	}
}
示例#2
0
// Verify that resource.RESTClients constructed from a factory respect mapping.APIVersion
func TestClientVersions(t *testing.T) {
	f := NewFactory(nil)

	versions := []string{
		"v1beta1",
		"v1beta2",
		"v1beta3",
	}
	for _, version := range versions {
		mapping := &meta.RESTMapping{
			APIVersion: version,
		}
		c, err := f.RESTClient(mapping)
		if err != nil {
			t.Errorf("unexpected error: %v", err)
		}
		client := c.(*client.RESTClient)
		if client.APIVersion() != version {
			t.Errorf("unexpected Client APIVersion: %s %v", client.APIVersion, client)
		}
	}
}