Created
November 4, 2021 02:42
-
-
Save sonya/3ea4f2bcebfcaed2c8c3cf7be7f62f34 to your computer and use it in GitHub Desktop.
http request mocking code samples
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
func TestGetFixedValue(t *testing.T) { | |
defer gock.Off() | |
gock.New("https://example.com/fixedvalue"). | |
MatchHeader("Accept", "application/json"). | |
Get("/"). | |
Reply(200). | |
JSON(map[string]string{"value": "fixed"}) | |
value, _ := GetFixedValue("https://example.com") | |
if value != "fixed" { | |
t.Errorf("Expected 'fixed', got %s", value) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment