forked from kata-containers/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
experimental_test.go
60 lines (50 loc) · 1.02 KB
/
experimental_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 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)
}
}
}