6
6
"io"
7
7
"strings"
8
8
"testing"
9
+ "time"
9
10
10
11
"github.com/go-resty/resty/v2"
11
12
"github.com/shellhub-io/shellhub/pkg/models"
@@ -52,6 +53,11 @@ func TestDevSetup(t *testing.T) {
52
53
description : "succeeds" ,
53
54
test : func (dockerCompose * DockerCompose ) (* Expected , error ) {
54
55
cli := dockerCompose .GetServiceCLI ()
56
+ networks , err := cli .Networks (context .TODO ())
57
+ if err != nil {
58
+ return nil , err
59
+ }
60
+ logrus .Info (networks )
55
61
56
62
// Try to create a new user
57
63
_ , reader , err := cli .Exec (ctx , strings .Split ("./cli user create john_doe secret john.doe@test.com" , " " ))
@@ -63,6 +69,7 @@ func TestDevSetup(t *testing.T) {
63
69
if err := ReadToString (reader , & userRes ); err != nil {
64
70
return nil , err
65
71
}
72
+ logrus .Info (userRes )
66
73
67
74
// Try to create a new namespace
68
75
_ , reader , err = cli .Exec (ctx , strings .Split ("./cli namespace create dev john_doe 00000000-0000-4000-0000-000000000000" , " " ))
@@ -74,9 +81,10 @@ func TestDevSetup(t *testing.T) {
74
81
if err := ReadToString (reader , & nsRes ); err != nil {
75
82
return nil , err
76
83
}
84
+ logrus .Info (nsRes )
77
85
78
86
userAuth := new (models.UserAuthResponse )
79
- _ , err = resty .
87
+ res1 , err : = resty .
80
88
New ().
81
89
R ().
82
90
SetBody (map [string ]string {
@@ -88,9 +96,13 @@ func TestDevSetup(t *testing.T) {
88
96
if err != nil {
89
97
return nil , err
90
98
}
99
+ logrus .Info (res1 .Status ())
100
+ logrus .Info (string (res1 .Body ()))
101
+
102
+ time .Sleep (60 * time .Second )
91
103
92
104
devicesList := make ([]models.Device , 1 )
93
- res , err := resty .
105
+ res2 , err := resty .
94
106
New ().
95
107
R ().
96
108
SetHeader ("authorization" , fmt .Sprintf ("Bearer %s" , userAuth .Token )).
@@ -102,8 +114,8 @@ func TestDevSetup(t *testing.T) {
102
114
for _ , device := range devicesList {
103
115
logrus .Infof ("%+v" , device )
104
116
}
105
-
106
- logrus .Info ("body: " , string (res .Body ()))
117
+ logrus . Info ( res2 . Status ())
118
+ logrus .Info (string (res2 .Body ()))
107
119
108
120
_ , err = resty .
109
121
New ().
@@ -114,6 +126,8 @@ func TestDevSetup(t *testing.T) {
114
126
return nil , err
115
127
}
116
128
129
+ time .Sleep (60 * time .Second )
130
+
117
131
devicesList = make ([]models.Device , 1 )
118
132
_ , err = resty .
119
133
New ().
@@ -141,12 +155,12 @@ func TestDevSetup(t *testing.T) {
141
155
},
142
156
}
143
157
144
- for _ , tt := range cases {
158
+ for i , tt := range cases {
145
159
tc := tt
146
160
147
161
t .Run (tc .description , func (t * testing.T ) {
148
162
t .Parallel ()
149
- dockerCompose := instance .Clone ()
163
+ dockerCompose := instance .Clone (). WithEnv ( "SHELLHUB_NETWORK" , fmt . Sprintf ( "shellhub_network_%d" , i + 1 ))
150
164
151
165
teardown , err := dockerCompose .Start ()
152
166
if ! assert .NoError (t , err ) {
0 commit comments