8
8
"net/http"
9
9
"testing"
10
10
11
+ "github.com/stretchr/testify/assert"
11
12
"github.com/stretchr/testify/require"
12
13
13
14
"gitlab.com/gitlab-org/gitlab-shell/v14/client/testserver"
@@ -24,32 +25,32 @@ func TestExecuteEOFSent(t *testing.T) {
24
25
Path : "/geo/proxy/info_refs_receive_pack" ,
25
26
Handler : func (w http.ResponseWriter , r * http.Request ) {
26
27
b , err := io .ReadAll (r .Body )
27
- require .NoError (t , err )
28
+ assert .NoError (t , err )
28
29
29
30
var request * Request
30
- require .NoError (t , json .Unmarshal (b , & request ))
31
+ assert .NoError (t , json .Unmarshal (b , & request ))
31
32
32
- require .Equal (t , request .Data .UserID , who )
33
- require .Empty (t , request .Output )
33
+ assert .Equal (t , request .Data .UserID , who )
34
+ assert .Empty (t , request .Output )
34
35
35
36
err = json .NewEncoder (w ).Encode (Response {Result : []byte ("custom" )})
36
- require .NoError (t , err )
37
+ assert .NoError (t , err )
37
38
},
38
39
},
39
40
{
40
41
Path : "/geo/proxy/receive_pack" ,
41
42
Handler : func (w http.ResponseWriter , r * http.Request ) {
42
43
b , err := io .ReadAll (r .Body )
43
- require .NoError (t , err )
44
+ assert .NoError (t , err )
44
45
45
46
var request * Request
46
- require .NoError (t , json .Unmarshal (b , & request ))
47
+ assert .NoError (t , json .Unmarshal (b , & request ))
47
48
48
- require .Equal (t , request .Data .UserID , who )
49
- require .Equal (t , "0009input" , string (request .Output ))
49
+ assert .Equal (t , request .Data .UserID , who )
50
+ assert .Equal (t , "0009input" , string (request .Output ))
50
51
51
52
err = json .NewEncoder (w ).Encode (Response {Result : []byte ("output" )})
52
- require .NoError (t , err )
53
+ assert .NoError (t , err )
53
54
},
54
55
},
55
56
}
@@ -82,7 +83,7 @@ func TestExecuteEOFSent(t *testing.T) {
82
83
83
84
// expect printing of info message, "custom" string from the first request
84
85
// and "output" string from the second request
85
- require .Equal (t , "customoutput" , outBuf .String ())
86
+ assert .Equal (t , "customoutput" , outBuf .String ())
86
87
}
87
88
88
89
func TestExecuteNoEOFSent (t * testing.T ) {
@@ -93,32 +94,32 @@ func TestExecuteNoEOFSent(t *testing.T) {
93
94
Path : "/geo/proxy/info_refs_upload_pack" ,
94
95
Handler : func (w http.ResponseWriter , r * http.Request ) {
95
96
b , err := io .ReadAll (r .Body )
96
- require .NoError (t , err )
97
+ assert .NoError (t , err )
97
98
98
99
var request * Request
99
- require .NoError (t , json .Unmarshal (b , & request ))
100
+ assert .NoError (t , json .Unmarshal (b , & request ))
100
101
101
- require .Equal (t , request .Data .UserID , who )
102
- require .Empty (t , request .Output )
102
+ assert .Equal (t , request .Data .UserID , who )
103
+ assert .Empty (t , request .Output )
103
104
104
105
err = json .NewEncoder (w ).Encode (Response {Result : []byte ("custom" )})
105
- require .NoError (t , err )
106
+ assert .NoError (t , err )
106
107
},
107
108
},
108
109
{
109
110
Path : "/geo/proxy/upload_pack" ,
110
111
Handler : func (w http.ResponseWriter , r * http.Request ) {
111
112
b , err := io .ReadAll (r .Body )
112
- require .NoError (t , err )
113
+ assert .NoError (t , err )
113
114
114
115
var request * Request
115
- require .NoError (t , json .Unmarshal (b , & request ))
116
+ assert .NoError (t , json .Unmarshal (b , & request ))
116
117
117
- require .Equal (t , request .Data .UserID , who )
118
- require .Equal (t , "0032want 343d70886785dc1f98aaf70f3b4ca87c93a5d0dd\n " , string (request .Output ))
118
+ assert .Equal (t , request .Data .UserID , who )
119
+ assert .Equal (t , "0032want 343d70886785dc1f98aaf70f3b4ca87c93a5d0dd\n " , string (request .Output ))
119
120
120
121
err = json .NewEncoder (w ).Encode (Response {Result : []byte ("output" )})
121
- require .NoError (t , err )
122
+ assert .NoError (t , err )
122
123
},
123
124
},
124
125
}
@@ -151,5 +152,5 @@ func TestExecuteNoEOFSent(t *testing.T) {
151
152
152
153
// expect printing of info message, "custom" string from the first request
153
154
// and "output" string from the second request
154
- require .Equal (t , "customoutput" , outBuf .String ())
155
+ assert .Equal (t , "customoutput" , outBuf .String ())
155
156
}
0 commit comments