11// Package postman_test contains examples of gostman using Postman Echo. 
22// The following list are comparison of hierarchy between gostman and gostman. 
33// 
4- // 	 - The package postman_test is equal to collection in the postman 
5- // 	 - All tests in the form of TextXxx equal to folder in the postman (gostman doesn't support recursive folder) 
6- // 	 - Request itself is running in the subtests 
4+ //    - The package postman_test is equal to collection in the postman 
5+ //    - All tests in the form of TextXxx equal to folder in the postman (gostman doesn't support recursive folder) 
6+ //    - Request itself is running in the subtests 
77package  postman_test
88
99import  (
@@ -13,8 +13,8 @@ import (
1313	"os" 
1414	"testing" 
1515
16- 	"github.com/injustease /gostman" 
17- 	"github.com/injustease/is " 
16+ 	"github.com/minizilla /gostman" 
17+ 	"github.com/minizilla/testr " 
1818)
1919
2020type  postmanResponse  struct  {
@@ -31,6 +31,10 @@ func TestMain(m *testing.M) {
3131// TestRequest tests request to postman-echo. 
3232// go test -run Request 
3333func  TestRequest (t  * testing.T ) {
34+ 	if  testing .Short () {
35+ 		t .SkipNow ()
36+ 	}
37+ 
3438	gm  :=  gostman .New (t )
3539
3640	// go test -run Request/Params 
@@ -43,14 +47,14 @@ func TestRequest(t *testing.T) {
4347		r .Send (func (t  * testing.T , req  * http.Request , res  * http.Response ) {
4448			defer  res .Body .Close ()
4549
46- 			is  :=  is .New (t )
47- 			is .Equal (res .StatusCode , http .StatusOK )
50+ 			assert  :=  testr .New (t )
51+ 			assert .Equal (res .StatusCode , http .StatusOK )
4852
4953			var  resp  postmanResponse 
5054			err  :=  json .NewDecoder (res .Body ).Decode (& resp )
51- 			is . NoError (err )
52- 			is .Equal (resp .Args ["foo1" ], "bar1" )
53- 			is .Equal (resp .Args ["foo2" ], "bar2" )
55+ 			assert . ErrorIs (err ,  nil )
56+ 			assert .Equal (resp .Args ["foo1" ], "bar1" )
57+ 			assert .Equal (resp .Args ["foo2" ], "bar2" )
5458		})
5559	})
5660
@@ -64,13 +68,13 @@ func TestRequest(t *testing.T) {
6468		r .Send (func (t  * testing.T , req  * http.Request , res  * http.Response ) {
6569			defer  res .Body .Close ()
6670
67- 			is  :=  is .New (t )
68- 			is .Equal (res .StatusCode , http .StatusOK )
71+ 			assert  :=  testr .New (t )
72+ 			assert .Equal (res .StatusCode , http .StatusOK )
6973
7074			var  resp  postmanResponse 
7175			err  :=  json .NewDecoder (res .Body ).Decode (& resp )
72- 			is . NoError (err )
73- 			is . True (resp .Authenticated )
76+ 			assert . ErrorIs (err ,  nil )
77+ 			assert . Equal (resp .Authenticated ,  true )
7478		})
7579	})
7680
@@ -84,14 +88,14 @@ func TestRequest(t *testing.T) {
8488		r .Send (func (t  * testing.T , req  * http.Request , res  * http.Response ) {
8589			defer  res .Body .Close ()
8690
87- 			is  :=  is .New (t )
88- 			is .Equal (res .StatusCode , http .StatusOK )
91+ 			assert  :=  testr .New (t )
92+ 			assert .Equal (res .StatusCode , http .StatusOK )
8993
9094			var  resp  postmanResponse 
9195			err  :=  json .NewDecoder (res .Body ).Decode (& resp )
92- 			is . NoError (err )
93- 			is .Equal (resp .Headers ["foo1" ], "bar1" )
94- 			is .Equal (resp .Headers ["foo2" ], "bar2" )
96+ 			assert . ErrorIs (err ,  nil )
97+ 			assert .Equal (resp .Headers ["foo1" ], "bar1" )
98+ 			assert .Equal (resp .Headers ["foo2" ], "bar2" )
9599		})
96100	})
97101
@@ -104,22 +108,26 @@ func TestRequest(t *testing.T) {
104108		r .Send (func (t  * testing.T , req  * http.Request , res  * http.Response ) {
105109			defer  res .Body .Close ()
106110
107- 			is  :=  is .New (t )
108- 			is .Equal (res .StatusCode , http .StatusOK )
111+ 			assert  :=  testr .New (t )
112+ 			assert .Equal (res .StatusCode , http .StatusOK )
109113
110114			var  resp  postmanResponse 
111115			err  :=  json .NewDecoder (res .Body ).Decode (& resp )
112- 			is . NoError (err )
113- 			is .Equal (resp .Data , text )
116+ 			assert . ErrorIs (err ,  nil )
117+ 			assert .Equal (resp .Data , text )
114118		})
115119	})
116120}
117121
118122// TestVariable tests request to postman-echo with variable. 
119123// 
120- //   Set env: go test -run Variable -env postman 
121- //   Set env for the future request too: go test -run Variable -setenv postman 
124+ //	 Set env: go test -run Variable -env postman 
125+ //	 Set env for the future request too: go test -run Variable -setenv postman 
122126func  TestVariable (t  * testing.T ) {
127+ 	if  testing .Short () {
128+ 		t .SkipNow ()
129+ 	}
130+ 
123131	gm  :=  gostman .New (t )
124132
125133	// go test -run Variable/Authorization -env postman 
@@ -132,13 +140,13 @@ func TestVariable(t *testing.T) {
132140		r .Send (func (t  * testing.T , req  * http.Request , res  * http.Response ) {
133141			defer  res .Body .Close ()
134142
135- 			is  :=  is .New (t )
136- 			is .Equal (res .StatusCode , http .StatusOK )
143+ 			assert  :=  testr .New (t )
144+ 			assert .Equal (res .StatusCode , http .StatusOK )
137145
138146			var  resp  postmanResponse 
139147			err  :=  json .NewDecoder (res .Body ).Decode (& resp )
140- 			is . NoError (err )
141- 			is . True (resp .Authenticated )
148+ 			assert . ErrorIs (err ,  nil )
149+ 			assert . Equal (resp .Authenticated ,  true )
142150		})
143151	})
144152}
0 commit comments