Hey guys, I don't understand some behavior from my...
# pact-go
b
Hey guys, I don't understand some behavior from my pact provider, I set up my host as localhost:8081, but when I ran my tests I got a log from a request to a random port like localhost:36471, Is that ok? Am I missing some config? By the way I am writing the Provider part for the basic example at github. My code:
Copy code
func TestProductAPIProvider(t *testing.T) {
	go startServer()

	verifier := provider.NewVerifier()

	f := func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			log.Println("Alterando Response")
			requestFilterCalled = true
			next.ServeHTTP(w, r)
		})
	}


	err := verifier.VerifyProvider(t, provider.VerifyRequest{
		ProviderBaseURL: "<http://127.0.0.1:8001>",
		Provider:        "PactGoProductAPI",
		ProviderVersion: "v1",
		PactFiles: []string{
			filepath.ToSlash(fmt.Sprintf("%s/PactGoProductAPIConsumer-PactGoProductAPI.json", pactDir)),
		},
		RequestFilter:              f,
		PublishVerificationResults: false,
	})

	assert.NoError(t, err)
	assert.True(t, requestFilterCalled)
}

func startServer() {
	mux := http.NewServeMux()

	mux.HandleFunc("/products/{id}", func(w http.ResponseWriter, req *http.Request) {
		w.Header().Add("Content-Type", "application/json")
		fmt.Fprintf(w, `
		{
			"id":10,
			"type":"CREDIT_CARD",
			"name":"PS5",
			"version":"v2"
		}`)
	})
	log.Fatal(http.ListenAndServe("127.0.0.1:8001", mux))
}