11package exec
22
33import (
4- "github.com/stretchr/testify/require"
5- "testing"
4+ "github.com/stretchr/testify/require"
5+ "testing"
66)
77
88func TestServer_AddRole (t * testing.T ) {
@@ -16,12 +16,54 @@ func TestServer_AddRole(t *testing.T) {
1616}
1717
1818func TestServer_HasRole (t * testing.T ) {
19- s := & server {
20- Name : "qa" ,
21- Dsn : "root@domain.com" ,
22- }
23- s .AddRole ("qa" )
24-
25- require .True (t , s .HasRole ("qa" ))
26- require .False (t , s .HasRole ("test" ))
27- }
19+ s := & server {
20+ Name : "qa" ,
21+ Dsn : "root@domain.com" ,
22+ }
23+ s .AddRole ("qa" )
24+
25+ require .True (t , s .HasRole ("qa" ))
26+ require .False (t , s .HasRole ("test" ))
27+ }
28+
29+ func TestServer_Set (t * testing.T ) {
30+ s := & server {
31+ Name : "qa" ,
32+ Dsn : "root@domain.com" ,
33+ Configs : make (map [string ]* config ),
34+ }
35+ s .Set ("config" , "value" )
36+
37+ require .Contains (t , s .Configs , "config" )
38+ require .Equal (t , s .Configs ["config" ].Value (), "value" )
39+ }
40+
41+ func TestServer_Key (t * testing.T ) {
42+ s := & server {
43+ Name : "qa" ,
44+ Dsn : "root@domain.com" ,
45+ Configs : make (map [string ]* config ),
46+ sshClient : & sshClient {},
47+ }
48+ s .Key ("key" )
49+
50+ require .Contains (t , s .sshClient .keys , "key" )
51+ }
52+
53+ func TestServer_GetUser (t * testing.T ) {
54+ s := & server {
55+ Name : "qa" ,
56+ Dsn : "root@domain.com" ,
57+ }
58+
59+ require .Equal (t , s .GetUser (), "root" )
60+ }
61+
62+ func TestServer_GetHost (t * testing.T ) {
63+ s := & server {
64+ Name : "qa" ,
65+ Dsn : "root@domain.com" ,
66+ }
67+
68+ require .Equal (t , s .GetHost (), "domain.com" )
69+ }
0 commit comments