Last active
December 5, 2021 04:54
-
-
Save josephwoodward/762bb2e13bb8c37b0b8253c8d1532cad to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
toxiproxy "github.com/Shopify/toxiproxy/v2/client" | |
"os" | |
"testing" | |
) | |
var client *toxiproxy.Client | |
func TestMain(m *testing.M) { | |
upstreamService := "localhost:8080" | |
listen := "localhost:5050" | |
// Connect to the proxy server and create a proxy which we'll configure in individual test methods. | |
client = toxiproxy.NewClient("localhost:8474") | |
proxy, err := client.CreateProxy("upstream_api", listen, upstreamService) | |
if err != nil { | |
panic(err) | |
} | |
// Clean up the proxy once all tests have run | |
defer proxy.Delete() | |
os.Exit(m.Run()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment