Hey guys, I want to clarify some points that I fou...
# pact-go
b
Hey guys, I want to clarify some points that I found reading the explanation from the consumer message test: • I didn't find the NewMessagePactV3 function inside the repository... Has it upgraded or changed this method? • I also didn't find the type AsynchronousMessage... We are using inside de userHandlerWrapper that we assume as our adapter, abstracting the implementation and focusing on validating the content of the message. • How can I publish the contract from this test to a Pact Broker?
m
You're right, the V3 suffix was replaced with a package instead: here's a working example https://github.com/pact-foundation/pact-go/blob/781c59aa2b450d23bcbb566f71ec2986061ac3ac/examples/consumer_v3_test.go#L14
1
Publishing is the same as regular Pact. A contract will be generated and you would use the CLI tools to publish the contract
b
I've got the part from the suffix, and about the contract, Shouldn't we specify the directory to generate the file? I saw that the struct Config has Consumer, Provider, and PactDir as attributes..
Copy code
type Config struct {
	Consumer string
	Provider string
	PactDir  string
}
So in the end of the TestMessagePact we didn't declare this part
Copy code
provider, err := message.NewMessagePact(message.Config{
		Consumer: "PactGoV3MessageConsumer",
		Provider: "V3MessageProvider", // must be different to the HTTP one, can't mix both interaction styles
	})
I think I found the logic to store the files from the pact. If It's empty, It creates a new folder named pacts and put it inside..
Copy code
func (p *AsynchronousPact) validateConfig() error {
	log.Println("[DEBUG] pact message validate config")
	dir, _ := os.Getwd()

	if p.config.PactDir == "" {
		p.config.PactDir = filepath.Join(dir, "pacts")
	}

	p.messageserver = mockserver.NewMessageServer(p.config.Consumer, p.config.Provider)

	return nil
}