-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserver_test.go
69 lines (56 loc) · 1.21 KB
/
server_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
61
62
63
64
65
66
67
68
69
package exec
import (
"github.com/stretchr/testify/require"
"testing"
)
func TestServer_AddRole(t *testing.T) {
s := &server{
Name: "qa",
Dsn: "root@domain.com",
}
s.AddRole("qa").AddRole("test")
require.Equal(t, s.roles, []string{"qa", "test"})
}
func TestServer_HasRole(t *testing.T) {
s := &server{
Name: "qa",
Dsn: "root@domain.com",
}
s.AddRole("qa")
require.True(t, s.HasRole("qa"))
require.False(t, s.HasRole("test"))
}
func TestServer_Set(t *testing.T) {
s := &server{
Name: "qa",
Dsn: "root@domain.com",
Configs: make(map[string]*config),
}
s.Set("config", "value")
require.Contains(t, s.Configs, "config")
require.Equal(t, s.Configs["config"].Value(), "value")
}
func TestServer_Key(t *testing.T) {
s := &server{
Name: "qa",
Dsn: "root@domain.com",
Configs: make(map[string]*config),
sshClient: &sshClient{},
}
s.Key("key")
require.Contains(t, s.sshClient.keys, "key")
}
func TestServer_GetUser(t *testing.T) {
s := &server{
Name: "qa",
Dsn: "root@domain.com",
}
require.Equal(t, s.GetUser(), "root")
}
func TestServer_GetHost(t *testing.T) {
s := &server{
Name: "qa",
Dsn: "root@domain.com",
}
require.Equal(t, s.GetHost(), "domain.com")
}