-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(curl): getCurlCmd should not send request
- Loading branch information
Showing
24 changed files
with
112 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
/** | ||
* refer to: [email protected]:go-resty/resty.git | ||
*/ | ||
package examples | ||
|
||
import ( | ||
|
@@ -13,8 +10,9 @@ import ( | |
"github.com/go-resty/resty/v3" | ||
) | ||
|
||
// test context: cancel multi | ||
// Example about cancel request with context | ||
func TestSetContextCancelMulti(t *testing.T) { | ||
// 0. Init test server | ||
ts := createTestServer(func(w http.ResponseWriter, r *http.Request) { | ||
time.Sleep(2 * time.Microsecond) | ||
n, err := w.Write([]byte("TestSetContextCancel: response")) | ||
|
@@ -23,28 +21,28 @@ func TestSetContextCancelMulti(t *testing.T) { | |
}, 0) | ||
defer ts.Close() | ||
|
||
// client | ||
// 1. Create client | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
client := resty.New().R().SetContext(ctx) | ||
go func() { | ||
time.Sleep(1 * time.Microsecond) | ||
cancel() | ||
}() | ||
|
||
// first | ||
// 2. First request | ||
_, err := client.Get(ts.URL + "/get") | ||
if !errIsContextCancel(err) { | ||
t.Fatalf("Got unexpected error: %v", err) | ||
} | ||
|
||
// second | ||
// 3. Second request | ||
_, err = client.Get(ts.URL + "/get") | ||
if !errIsContextCancel(err) { | ||
t.Fatalf("Got unexpected error: %v", err) | ||
} | ||
} | ||
|
||
// test context: cancel with chan | ||
// Test context: cancel with chan | ||
func TestSetContextCancelWithChan(t *testing.T) { | ||
ch := make(chan struct{}) | ||
ts := createTestServer(func(w http.ResponseWriter, r *http.Request) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
/** | ||
* refer to: [email protected]:go-resty/resty.git | ||
*/ | ||
package examples | ||
|
||
import ( | ||
|
@@ -9,7 +6,7 @@ import ( | |
"github.com/go-resty/resty/v3" | ||
) | ||
|
||
// test context: cancel multi | ||
// Example about getting trace info | ||
func TestTrace(t *testing.T) { | ||
ts := createHttpbinServer(0) | ||
defer ts.Close() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.