mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-04 23:14:19 +01:00
Fixes #1226 Add new flag "experimental" for supporting underworking features. Some features are under developing which are not ready for release, there're also some features which will break compatibility which is not suitable to be merged into a kata minor release(x version in x.y.z) For getting these features above merged earlier for more testing, we can mark them as "experimental" features, and move them to formal features when they are ready. Signed-off-by: Wei Zhang <zhangwei555@huawei.com>
61 lines
1.0 KiB
Go
61 lines
1.0 KiB
Go
// Copyright (c) 2019 Huawei Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package experimental
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestExperimental(t *testing.T) {
|
|
f := Feature{
|
|
Name: "mock",
|
|
Description: "mock experimental feature for test",
|
|
ExpRelease: "2.0",
|
|
}
|
|
assert.Nil(t, Get(f.Name))
|
|
|
|
err := Register(f)
|
|
assert.Nil(t, err)
|
|
|
|
err = Register(f)
|
|
assert.NotNil(t, err)
|
|
assert.Equal(t, len(supportedFeatures), 1)
|
|
|
|
assert.NotNil(t, Get(f.Name))
|
|
}
|
|
|
|
func TestValidateFeature(t *testing.T) {
|
|
f := Feature{}
|
|
assert.NotNil(t, validateFeature(f))
|
|
|
|
for _, names := range []struct {
|
|
name string
|
|
valid bool
|
|
}{
|
|
{"mock_test_1", true},
|
|
{"m1234ock_test_1", true},
|
|
{"1_mock_test", false},
|
|
{"_mock_test_1", false},
|
|
{"Mock", false},
|
|
{"mock*&", false},
|
|
} {
|
|
f := Feature{
|
|
Name: names.name,
|
|
Description: "test",
|
|
ExpRelease: "2.0",
|
|
}
|
|
|
|
err := validateFeature(f)
|
|
if names.valid {
|
|
assert.Nil(t, err)
|
|
} else {
|
|
assert.NotNil(t, err)
|
|
}
|
|
}
|
|
}
|