-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed invalid test name and added validation in TestLongPlay()
- Loading branch information
seborama
committed
Nov 3, 2018
1 parent
b64c9d9
commit 38e6ac5
Showing
4 changed files
with
72 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package govcr_test | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"strings" | ||
|
||
"github.com/seborama/govcr" | ||
) | ||
|
||
const example4CassetteName = "MyCassette4" | ||
|
||
func runTestEx4() { | ||
// Create vcr and make http call | ||
vcr := govcr.NewVCR(example4CassetteName, nil) | ||
resp, _ := vcr.Client.Get("http://www.example.com/foo") | ||
|
||
// Show results | ||
fmt.Printf("%d ", resp.StatusCode) | ||
fmt.Printf("%s ", resp.Header.Get("Content-Type")) | ||
|
||
body, _ := ioutil.ReadAll(resp.Body) | ||
resp.Body.Close() | ||
fmt.Printf("%v ", strings.Contains(string(body), "domain in examples without prior coordination or asking for permission.")) | ||
|
||
fmt.Printf("%+v\n", vcr.Stats()) | ||
} | ||
|
||
// Example_simpleVCR is an example use of govcr. | ||
// It shows a simple use of a Long Play cassette (i.e. compressed). | ||
func Example_number4SimpleVCR() { | ||
// Delete cassette to enable live HTTP call | ||
govcr.DeleteCassette(example4CassetteName, "") | ||
|
||
// 1st run of the test - will use live HTTP calls | ||
runTestEx4() | ||
// 2nd run of the test - will use playback | ||
runTestEx4() | ||
|
||
// Output: | ||
// 404 text/html; charset=UTF-8 true {TracksLoaded:0 TracksRecorded:1 TracksPlayed:0} | ||
// 404 text/html; charset=UTF-8 true {TracksLoaded:1 TracksRecorded:0 TracksPlayed:1} | ||
} |
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