2015-04-14 16:29:33 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2015 The Kubernetes Authors.
|
2015-04-14 16:29:33 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package volume
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2015-08-05 22:03:47 +00:00
|
|
|
"k8s.io/kubernetes/pkg/api"
|
2015-04-14 16:29:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSpecSourceConverters(t *testing.T) {
|
|
|
|
v := &api.Volume{
|
|
|
|
Name: "foo",
|
|
|
|
VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}},
|
|
|
|
}
|
|
|
|
|
|
|
|
converted := NewSpecFromVolume(v)
|
2015-08-12 19:11:03 +00:00
|
|
|
if converted.Volume.EmptyDir == nil {
|
2016-06-14 12:04:38 +00:00
|
|
|
t.Errorf("Unexpected nil EmptyDir: %#v", converted)
|
2015-04-14 16:29:33 +00:00
|
|
|
}
|
2015-08-12 19:11:03 +00:00
|
|
|
if v.Name != converted.Name() {
|
|
|
|
t.Errorf("Expected %v but got %v", v.Name, converted.Name())
|
2015-04-14 16:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pv := &api.PersistentVolume{
|
|
|
|
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
|
|
|
Spec: api.PersistentVolumeSpec{
|
|
|
|
PersistentVolumeSource: api.PersistentVolumeSource{AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{}},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2015-06-26 20:37:11 +00:00
|
|
|
converted = NewSpecFromPersistentVolume(pv, false)
|
2015-08-12 19:11:03 +00:00
|
|
|
if converted.PersistentVolume.Spec.AWSElasticBlockStore == nil {
|
2016-06-14 12:04:38 +00:00
|
|
|
t.Errorf("Unexpected nil AWSElasticBlockStore: %#v", converted)
|
2015-04-14 16:29:33 +00:00
|
|
|
}
|
2015-08-12 19:11:03 +00:00
|
|
|
if pv.Name != converted.Name() {
|
|
|
|
t.Errorf("Expected %v but got %v", pv.Name, converted.Name())
|
2015-04-14 16:29:33 +00:00
|
|
|
}
|
|
|
|
}
|