-
-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviortriageThis issue is yet to be triaged by a maintainerThis issue is yet to be triaged by a maintainer
Description
Software versions
- OS: e.g. Mac OSX 10.11.5
- Consumer Pact library: Pact go v2.0.1
- Golang Version:
go1.20.5 - Golang environment: Provide output of
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/dev/.cache/go-build" GOENV="/home/dev/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/dev/go/pkg/mod" GONOPROXY="github.hpe.com" GONOSUMDB="github.hpe.com" GOOS="linux" GOPATH="/home/dev/go" GOPRIVATE="github.hpe.com" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.20.5" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/dev/ws/pact-go/go.mod" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1831304596=/tmp/go-build -gno-record-gcc-switches"
Expected behaviour
Adding WithMetadata() to record headers in the example documented here, does not add metadata details to the contract.
Actual behaviour
Would like to see headers added to the contract
Steps to reproduce
Run the below test
//go:build consumer
// +build consumer
package protobuf
import (
"fmt"
"os"
"path/filepath"
"testing"
message "github.com/pact-foundation/pact-go/v2/message/v4"
"github.com/stretchr/testify/assert"
)
var dir, _ = os.Getwd()
func TestPluginMessageConsumer(t *testing.T) {
p, _ := message.NewAsynchronousPact(message.Config{
Consumer: "protobufmessageconsumer",
Provider: "protobufmessageprovider",
PactDir: filepath.ToSlash(fmt.Sprintf("%s/../pacts", dir)),
})
kafkaHeaders := map[string]string{
"specversion": "1.0",
"type": "eventName",
"source": "sourceName",
}
dir, _ := os.Getwd()
path := fmt.Sprintf("%s/../grpc/routeguide/route_guide.proto", dir)
protoMessage := `{
"pact:proto": "` + path + `",
"pact:message-type": "Feature",
"pact:content-type": "application/protobuf",
"name": "notEmpty('Big Tree')",
"location": {
"latitude": "matching(number, 180)",
"longitude": "matching(number, 200)"
}
}`
err := p.AddAsynchronousMessage().
Given("the world exists").
ExpectsToReceive("feature message").
WithMetadata(kafkaHeaders).
UsingPlugin(message.PluginConfig{
Plugin: "protobuf",
Version: "0.3.4",
}).
WithContents(protoMessage, "application/protobuf").
ExecuteTest(t, func(m message.AsynchronousMessage) error {
return nil
})
assert.NoError(t, err)
}
Relevent log files
Please ensure you set logging to DEBUG and attach any relevant log files here (or link from a gist).
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviortriageThis issue is yet to be triaged by a maintainerThis issue is yet to be triaged by a maintainer
Type
Projects
Status
New Issue