...
1
15
16 package gates
17
18 import (
19 "os"
20 "testing"
21 )
22
23 const name string = "HELM_EXPERIMENTAL_FEATURE"
24
25 func TestIsEnabled(t *testing.T) {
26 os.Unsetenv(name)
27 g := Gate(name)
28
29 if g.IsEnabled() {
30 t.Errorf("feature gate shows as available, but the environment variable %s was not set", name)
31 }
32
33 os.Setenv(name, "1")
34
35 if !g.IsEnabled() {
36 t.Errorf("feature gate shows as disabled, but the environment variable %s was set", name)
37 }
38 }
39
40 func TestError(t *testing.T) {
41 os.Unsetenv(name)
42 g := Gate(name)
43
44 if g.Error().Error() != "this feature has been marked as experimental and is not enabled by default. Please set HELM_EXPERIMENTAL_FEATURE=1 in your environment to use this feature" {
45 t.Errorf("incorrect error message. Received %s", g.Error().Error())
46 }
47 }
48
49 func TestString(t *testing.T) {
50 os.Unsetenv(name)
51 g := Gate(name)
52
53 if g.String() != "HELM_EXPERIMENTAL_FEATURE" {
54 t.Errorf("incorrect string representation. Received %s", g.String())
55 }
56 }
57
View as plain text