Files
kata-containers/virtcontainers/experimental/experimental_test.go
Wei Zhang 050f03bb36 config: Add config flag "experimental"
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>
2019-03-12 11:03:28 +08:00

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)
}
}
}