-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathstart_test.go
More file actions
59 lines (49 loc) · 1.32 KB
/
start_test.go
File metadata and controls
59 lines (49 loc) · 1.32 KB
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
package cmd
import (
"strings"
"testing"
"github.com/keep-network/keep-core/config"
"github.com/spf13/cobra"
)
func TestNetworkBootstrapFlagDescription_ContainsDeprecationNotice(t *testing.T) {
cmd := &cobra.Command{Use: "test"}
cfg := &config.Config{}
initNetworkFlags(cmd, cfg)
flag := cmd.Flags().Lookup("network.bootstrap")
if flag == nil {
t.Fatal("expected network.bootstrap flag to be registered")
}
usageLower := strings.ToLower(flag.Usage)
if !strings.Contains(usageLower, "deprecated") {
t.Errorf(
"expected flag description to contain deprecation notice, got: %q",
flag.Usage,
)
}
}
func TestIsBootstrap(t *testing.T) {
tests := map[string]struct {
bootstrapValue bool
expected bool
}{
"returns true when bootstrap flag is set": {
bootstrapValue: true,
expected: true,
},
"returns false when bootstrap flag is not set": {
bootstrapValue: false,
expected: false,
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
originalBootstrap := clientConfig.LibP2P.Bootstrap
defer func() { clientConfig.LibP2P.Bootstrap = originalBootstrap }()
clientConfig.LibP2P.Bootstrap = tc.bootstrapValue
got := isBootstrap()
if got != tc.expected {
t.Errorf("expected isBootstrap() to return %v, got %v", tc.expected, got)
}
})
}
}