@@ -23,11 +23,11 @@ import (
2323)
2424
2525type AuthSuccess struct {
26- Id , Message string
26+ ID , Message string
2727}
2828
2929type AuthError struct {
30- Id , Message string
30+ ID , Message string
3131}
3232
3333func TestGet (t * testing.T ) {
@@ -460,6 +460,7 @@ func TestFormData(t *testing.T) {
460460
461461 resp , err := c .R ().
462462 SetFormData (map [string ]string {"first_name" : "Jeevanandam" , "last_name" : "M" , "zip_code" : "00001" }).
463+ SetBasicAuth ("myuser" , "mypass" ).
463464 Post (ts .URL + "/profile" )
464465
465466 assertError (t , err )
@@ -551,7 +552,7 @@ func TestGetWithCookies(t *testing.T) {
551552 ts := createGetServer (t )
552553 defer ts .Close ()
553554
554- cookies := make ( []* http.Cookie , 0 )
555+ var cookies []* http.Cookie
555556
556557 cookies = append (cookies , & http.Cookie {
557558 Name : "go-resty-1" ,
@@ -730,6 +731,37 @@ func TestClientTimeout(t *testing.T) {
730731 assertEqual (t , true , strings .Contains (err .Error (), "i/o timeout" ))
731732}
732733
734+ func TestHeadMethod (t * testing.T ) {
735+ ts := createGetServer (t )
736+ defer ts .Close ()
737+
738+ resp , err := dclr ().Head (ts .URL + "/" )
739+
740+ assertError (t , err )
741+ assertEqual (t , http .StatusOK , resp .StatusCode ())
742+ }
743+
744+ func TestOptionsMethod (t * testing.T ) {
745+ ts := createGenServer (t )
746+ defer ts .Close ()
747+
748+ resp , err := dclr ().Options (ts .URL + "/options" )
749+
750+ assertError (t , err )
751+ assertEqual (t , http .StatusOK , resp .StatusCode ())
752+ assertEqual (t , resp .Header ().Get ("Access-Control-Expose-Headers" ), "x-go-resty-id" )
753+ }
754+
755+ func TestPatchMethod (t * testing.T ) {
756+ ts := createGenServer (t )
757+ defer ts .Close ()
758+
759+ resp , err := dclr ().Patch (ts .URL + "/patch" )
760+
761+ assertError (t , err )
762+ assertEqual (t , http .StatusOK , resp .StatusCode ())
763+ }
764+
733765func TestClientOptions (t * testing.T ) {
734766 c := dc ()
735767
@@ -958,6 +990,17 @@ func createGenServer(t *testing.T) *httptest.Server {
958990 w .Write ([]byte (`<?xml version="1.0" encoding="UTF-8"?><Response>XML response</Response>` ))
959991 }
960992 }
993+
994+ if r .Method == OPTIONS && r .URL .Path == "/options" {
995+ w .Header ().Set ("Access-Control-Allow-Origin" , "localhost" )
996+ w .Header ().Set ("Access-Control-Allow-Methods" , "PUT, PATCH" )
997+ w .Header ().Set ("Access-Control-Expose-Headers" , "x-go-resty-id" )
998+ w .WriteHeader (http .StatusOK )
999+ }
1000+
1001+ if r .Method == PATCH && r .URL .Path == "/patch" {
1002+ w .WriteHeader (http .StatusOK )
1003+ }
9611004 })
9621005
9631006 return ts
0 commit comments