66 "io"
77 "strings"
88 "testing"
9+ "time"
910
1011 "github.com/go-resty/resty/v2"
1112 "github.com/shellhub-io/shellhub/pkg/models"
@@ -52,6 +53,11 @@ func TestDevSetup(t *testing.T) {
5253 description : "succeeds" ,
5354 test : func (dockerCompose * DockerCompose ) (* Expected , error ) {
5455 cli := dockerCompose .GetServiceCLI ()
56+ networks , err := cli .Networks (context .TODO ())
57+ if err != nil {
58+ return nil , err
59+ }
60+ logrus .Info (networks )
5561
5662 // Try to create a new user
5763 _ ,
reader ,
err := cli .
Exec (
ctx ,
strings .
Split (
"./cli user create john_doe secret [email protected] " ,
" " ))
@@ -63,6 +69,7 @@ func TestDevSetup(t *testing.T) {
6369 if err := ReadToString (reader , & userRes ); err != nil {
6470 return nil , err
6571 }
72+ logrus .Info (userRes )
6673
6774 // Try to create a new namespace
6875 _ , 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) {
7481 if err := ReadToString (reader , & nsRes ); err != nil {
7582 return nil , err
7683 }
84+ logrus .Info (nsRes )
7785
7886 userAuth := new (models.UserAuthResponse )
79- _ , err = resty .
87+ res1 , err : = resty .
8088 New ().
8189 R ().
8290 SetBody (map [string ]string {
@@ -88,9 +96,13 @@ func TestDevSetup(t *testing.T) {
8896 if err != nil {
8997 return nil , err
9098 }
99+ logrus .Info (res1 .Status ())
100+ logrus .Info (string (res1 .Body ()))
101+
102+ time .Sleep (60 * time .Second )
91103
92104 devicesList := make ([]models.Device , 1 )
93- res , err := resty .
105+ res2 , err := resty .
94106 New ().
95107 R ().
96108 SetHeader ("authorization" , fmt .Sprintf ("Bearer %s" , userAuth .Token )).
@@ -102,8 +114,8 @@ func TestDevSetup(t *testing.T) {
102114 for _ , device := range devicesList {
103115 logrus .Infof ("%+v" , device )
104116 }
105-
106- logrus .Info ("body: " , string (res .Body ()))
117+ logrus . Info ( res2 . Status ())
118+ logrus .Info (string (res2 .Body ()))
107119
108120 _ , err = resty .
109121 New ().
@@ -114,6 +126,8 @@ func TestDevSetup(t *testing.T) {
114126 return nil , err
115127 }
116128
129+ time .Sleep (60 * time .Second )
130+
117131 devicesList = make ([]models.Device , 1 )
118132 _ , err = resty .
119133 New ().
@@ -141,12 +155,12 @@ func TestDevSetup(t *testing.T) {
141155 },
142156 }
143157
144- for _ , tt := range cases {
158+ for i , tt := range cases {
145159 tc := tt
146160
147161 t .Run (tc .description , func (t * testing.T ) {
148162 t .Parallel ()
149- dockerCompose := instance .Clone ()
163+ dockerCompose := instance .Clone (). WithEnv ( "SHELLHUB_NETWORK" , fmt . Sprintf ( "shellhub_network_%d" , i + 1 ))
150164
151165 teardown , err := dockerCompose .Start ()
152166 if ! assert .NoError (t , err ) {
0 commit comments