we can see that there are 2 new fields added to th...
# pact-go
v
we can see that there are 2 new fields added to the body:
Copy code
"contentType": "application/json",
"encoded": false
why does pact add them if we have header content-type?..
m
Can you please share your full test setup? It's probably a bug.
v
hi Matt! Sure:
Copy code
func (s *PicklistSuite) TestClosePicklist() {
	//contract description
	var retailer, env, code, token = "", "", "bbe797fd-b557-4549-9a5e-913a0d14b936", "token"
	mockProvider.AddInteraction().
		Given(fmt.Sprintf("picklist with code '%s' exists", code)).
		UponReceiving(fmt.Sprintf("a request to close picklist by code '%s'", code)).
		WithRequest(http.MethodPost, fmt.Sprintf("/v3/picklists/%s/close", code), func(b *consumer.V4RequestBuilder) {
			b.Header("X-Token", matchers.S(token))
		}).
		WillRespondWith(http.StatusOK, func(b *consumer.V4ResponseBuilder) {
			b.
				Header("Content-Type", matchers.S("application/json")).
				JSONBody(matchers.MapMatcher{
					"code":      matchers.S(code),
					"closed-at": matchers.Timestamp(),
				})
		},
		)

	// define test
	err := mockProvider.ExecuteTest(s.T(), func(config consumer.MockServerConfig) error {
		isps.URLFormat = fmt.Sprintf("<http://localhost>:%d/v3/", config.Port)
		isps.URLFormat = isps.URLFormat + "%s" + "%s"
		ctx := context.Background()
		params := isps.ClosePicklistReqParams{
			Retailer:     retailer,
			Env:          env,
			Token:        token,
			PicklistCode: code,
		}
		// execute function
		response, err := app.inStorePickingService.ClosePicklist(ctx, params)

		s.NoError(err)
		s.NotNil(response)
		s.Equal(code, response.Code)
		s.NotNil(response.ClosedAt)

		return nil
	})

	s.Require().NoError(err)
}
👍 1
m
How is the mock provider setup? Also after you clearing out the existing Pact file? Anything else in the setup you can share?
v
Copy code
mockProvider, err = consumer.NewV4Pact(consumer.MockHTTPProviderConfig{
   Consumer: "outboundbff-picklist",
   Provider: "isps",
   PactDir:  "../common/services/pacts",
})
btw didn't manage to setup logs... in prev version during pact init I specified LogDir...
I init mockProvider in SetupSuite() func (before all the tests)
nothing else is there...
when I run tests locally I remove the existing pact file
@Matt (pactflow.io / pact-js / pact-go) I've compared pacts generated with V2HTTPMockProvider, V3HTTPMockProvider and V4HTTPMockProvider. I guess this part
Copy code
"contentType": "application/json",
"encoded": false
appears only in V4 where we have body containing "content" and "contentType". Maybe pactflow should ignore contentType and encoded during pact and provide specification comparison.
m
Yeah, something is definitely not right here Viktoriia. Could you please raise a bug on the git repo?
v
sure , I will. Thank you!
👍 1
Finally I got to issue creation and I've found that even pact generated by the existing tests in 2.x.x branch has the mentioned fields. I've included the link to the lines: https://github.com/pact-foundation/pact-go/issues/273
m
Sorry I must have misread your original thread here. Are you having problems or not? The provider test in the repo passes, the contract file is just how Pact serialises the interaction.
Pactflow does not yet not how to properly render v4 pacts. This is coming soon, and is possibly why the confusion exists
v
ah! I guess that is my answer! "_*Pactflow does not yet not how to properly render v4 pacts.*_"
👍 1
when do you expect to add this? approximately
m
Sorry about the confusion. I must have felt there was a bug where the actual field was expected and the test was failing, but it's just how it shows in the UI
Aiming this quarter
v
cool! thank you very much
🙌 1
m
Np. I'll close off that issue
v
👍
and when is the plan to release 2.x.x as a stable version not beta?