I've removed the channel (in the past I introduced it there as I saw some asynchronous behaviour) so now the code seems like that:
``` verifyRequest.StateHandlers = models.StateHandlers{
"App myapp exists and has component gh-component and quay-component": createAppAndComponents(HASAppNamespace),
}```
and the method itself:
```func createAppAndComponents(HASAppNamespace string) models.StateHandler {
var stateHandler = func(setup bool, s models.ProviderState) (models.ProviderStateResponse, error) {
<some logic>
}
return stateHandler
}```
and this is log from the run:
```023-08-28T13:30:06.724217Z INFO ThreadId(13) pact_verifier: Running provider verification for 'Get app with its components.'
2023-08-28T15:30:06+02:00 INFO Stopping and waiting for webhooks
2023-08-28T15:30:06+02:00 INFO Wait completed, proceeding to shutdown the manager
2023-08-28T13:30:06.724298Z INFO ThreadId(13) pact_verifier::provider_client: Sending request to provider at
http://localhost:44835/
2023-08-28T13:30:06.724307Z INFO ThreadId(13) pact_verifier::provider_client: Sending request HTTP Request ( method: GET, path: /apis/appstudio.redhat.com/v1alpha1/namespaces/default/applications/myapp, query: None, headers: Some({"Content-type": ["application/json"]}), body: Missing )
2023-08-28T13:30:06.728033Z INFO ThreadId(13) pact_verifier::provider_client: Received response: HTTP Response ( status: 200, headers: Some({"content-length": ["1990"], "content-type": ["application/json"], "audit-id": ["1661d23b-781f-4cb2-b6ce-8c0483154de9"], "date": ["Mon, 28 Aug 2023 13:30:06 GMT"], "cache-control": ["no-cache", "private"], "x-kubernetes-pf-prioritylevel-uid": ["ad80173c-8794-407b-b8e8-4832c173cd9f"], "x-kubernetes-pf-flowschema-uid": ["c0ea09c8-f75f-416a-a4e9-f5bc9e03116b"]}), body: Present(1990 bytes, application/json) )
2023-08-28T13:30:06.728067Z INFO ThreadId(13) pact_matching: comparing to expected response: HTTP Response ( status: 200, headers: Some({"Content-Type": ["application/json"]}), body: Present(1063 bytes) )
2023-08-28T13:30:06.728824Z INFO ThreadId(13) pact_verifier: Running teardown provider state change handler 'App myapp exists and has component gh-component and quay-component' for 'Get app with its components.'
LOG: createAppAndComponents method was executed
2023/08/28 15:30:06 http: panic serving [::1]:33954:
Your test failed.
Ginkgo panics to prevent subsequent assertions from running.
Normally Ginkgo rescues this panic so you shouldn't see it.
But, if you make an assertion in a goroutine, Ginkgo can't capture the panic.
To circumvent this, you should call
defer GinkgoRecover()
at the top of the goroutine that caused this panic.
goroutine 705 [running]:
net/http.(*conn).serve.func1()
/usr/local/go/src/net/http/server.go:1825 +0xbf
panic({0x2285b20, 0x2da9290})
/usr/local/go/src/runtime/panic.go:844 +0x258
http://github.com/onsi/ginkgo.Fail({0xc000cbda40, 0x13f}, {0xc000ca4568?, 0xc000cbda40?, 0xc000e5b680?})
/home/katka/go/pkg/mod/github.com/onsi/ginkgo@v1.16.5/ginkgo_dsl.go:291 +0xdd
http://github.com/onsi/gomega/internal.(*Assertion).match(0xc00030df80, {0x2dc48e0, 0x437e1c8}, 0x1, {0x0, 0x0, 0x0})
/home/katka/go/pkg/mod/github.com/onsi/gomega@v1.24.1/internal/assertion.go:106 +0x1f0
http://github.com/onsi/gomega/internal.(*Assertion).Should(0xc00030df80, {0x2dc48e0, 0x437e1c8}, {0x0, 0x0, 0x0})
/home/katka/go/pkg/mod/github.com/onsi/gomega@v1.24.1/internal/assertion.go:50 +0xb5
http://github.com/redhat-appstudio/application-service/controllers.createAppAndComponents.func1(0x0?, {{0xc0012f1590?, 0xc000494c30?}, 0x42?})
/home/katka/hac/application-service/controllers/application_pact_test_state_handlers.go:46 +0x457
http://github.com/pact-foundation/pact-go/v2/provider.stateHandlerMiddleware.func1.1({0x2dd44b0, 0xc000a5e8c0}, 0xc0012ed400)
/home/katka/go/pkg/mod/github.com/pact-foundation/pact-go/v2@v2.0.0-beta.23/provider/verifier.go:295 +0x6b4
net/http.HandlerFunc.ServeHTTP(0x2db87a0?, {0x2dd44b0?, 0xc000a5e8c0?}, 0x440f76?)
/usr/local/go/src/net/http/server.go:2084 +0x2f
http://github.com/pact-foundation/pact-go/v2/proxy.chainHandlers.func1.1({0x2dd44b0, 0xc000a5e8c0}, 0xc000ac1240?)
/home/katka/go/pkg/mod/github.com/pact-foundation/pact-go/v2@v2.0.0-beta.23/proxy/http.go:68 +0x90
net/http.HandlerFunc.ServeHTTP(0x0?, {0x2dd44b0?, 0xc000a5e8c0?}, 0x413305?)
/usr/local/go/src/net/http/server.go:2084 +0x2f
net/http.serverHandler.ServeHTTP({0x2dc0e78?}, {0x2dd44b0, 0xc000a5e8c0}, 0xc0012ed400)
/usr/local/go/src/net/http/server.go:2916 +0x43b
net/http.(*conn).serve(0xc0009121e0, {0x2dd5b08, 0xc000b13dd0})
/usr/local/go/src/net/http/server.go:1966 +0x5d7
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:3071 +0x4db
2023-08-28T13:30:06.730080Z ERROR ThreadId(13) pact_verifier: Provider teardown state change for 'App myapp exists and has component gh-component and quay-component' has failed - MismatchResult::Error("Invalid response: error sending request for url (
http://localhost:44835/__setup): connection closed before message completed", None)```