@@ -40,6 +40,10 @@ func TestRequest_JSONBody(t *testing.T) {
4040 req = req .JSONBody (User {})
4141 assert .NotNil (t , req .req .Body )
4242 assert .Equal (t , "application/json" , req .req .Header .Get ("Content-Type" ))
43+
44+ req2 := NewRequest (context .Background (), http .MethodGet , "://localhost:80/a" )
45+ assert .NotNil (t , req2 .err )
46+ assert .Nil (t , req2 .req )
4347}
4448
4549func TestRequest_Do (t * testing.T ) {
@@ -103,6 +107,10 @@ func TestRequest_AddParam(t *testing.T) {
103107 AddParam ("key1" , "value1" ).
104108 AddParam ("key2" , "value2" )
105109 assert .Equal (t , "http://localhost?key1=value1&key2=value2" , req .req .URL .String ())
110+
111+ req2 := NewRequest (context .Background (), http .MethodGet , "://localhost:80/a" )
112+ assert .NotNil (t , req2 .err )
113+ assert .Nil (t , req2 .req )
106114}
107115
108116func TestRequestAddHeader (t * testing.T ) {
@@ -111,6 +119,10 @@ func TestRequestAddHeader(t *testing.T) {
111119 AddHeader ("head1" , "val1" ).AddHeader ("head1" , "val2" )
112120 vals := req .req .Header .Values ("head1" )
113121 assert .Equal (t , []string {"val1" , "val2" }, vals )
122+
123+ req2 := NewRequest (context .Background (), http .MethodGet , "://localhost:80/a" )
124+ assert .NotNil (t , req2 .err )
125+ assert .Nil (t , req2 .req )
114126}
115127
116128type User struct {
0 commit comments