Remove ExpStorageVersion and Add StorageVersions to APIServer struct

This commit is contained in:
Chao Xu
2015-09-21 15:57:05 -07:00
parent 1b8727ada1
commit c449baea46
5 changed files with 153 additions and 16 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package app
import (
"reflect"
"regexp"
"testing"
)
@@ -61,3 +62,39 @@ func TestLongRunningRequestRegexp(t *testing.T) {
}
}
}
func TestGenerateStorageVersionMap(t *testing.T) {
testCases := []struct {
legacyVersion string
storageVersions string
expectedMap map[string]string
}{
{
legacyVersion: "v1",
storageVersions: "v1,experimental/v1alpha1",
expectedMap: map[string]string{
"": "v1",
"experimental": "experimental/v1alpha1",
},
},
{
legacyVersion: "",
storageVersions: "experimental/v1alpha1,v1",
expectedMap: map[string]string{
"": "v1",
"experimental": "experimental/v1alpha1",
},
},
{
legacyVersion: "",
storageVersions: "",
expectedMap: map[string]string{},
},
}
for _, test := range testCases {
output := generateStorageVersionMap(test.legacyVersion, test.storageVersions)
if !reflect.DeepEqual(test.expectedMap, output) {
t.Errorf("unexpected error. expect: %v, got: %v", test.expectedMap, output)
}
}
}