Skip to content

Instantly share code, notes, and snippets.

@josephwoodward
Last active December 5, 2021 04:54
Show Gist options
  • Save josephwoodward/762bb2e13bb8c37b0b8253c8d1532cad to your computer and use it in GitHub Desktop.
Save josephwoodward/762bb2e13bb8c37b0b8253c8d1532cad to your computer and use it in GitHub Desktop.
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