Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find the definition of MessageVerifier #469

Closed
XuNeal opened this issue Dec 9, 2024 · 2 comments
Closed

Cannot find the definition of MessageVerifier #469

XuNeal opened this issue Dec 9, 2024 · 2 comments
Labels
documentation Indicates a need for improvements or additions to documentation good first issue Indicates a good issue for first-time contributors help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@XuNeal
Copy link

XuNeal commented Dec 9, 2024

Software versions

  • OS: 15.0.1
  • Consumer Pact library: Pact go v2.0.8
  • Provider Pact library: Pact go v2.0.8
  • Golang Version: go version go1.22.6 darwin/arm64
  • Golang environment:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/UserDir/Library/Caches/go-build'
GOENV='/UserDir/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/UserDir/go/pkg/mod'
GONOPROXY='xxxxx'
GONOSUMDB='xxxxx'
GOOS='darwin'
GOPATH='/UserDir/go'
GOPRIVATE='xxxxx'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/UserDir/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/UserDir/go/pkg/mod/golang.org/[email protected]/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.6'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/UserDir/xxxx/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/r5/23k2727j7xv5j2g3nzqk402r0000gn/T/go-build3723278093=/tmp/go-build -gno-record-gcc-switches -fno-common'

Expected behaviour

I'm writing a kafka test follow below example, from the link: https://docs.pact.io/implementation_guides/go/docs/messages#provider-producer

func TestV3MessageProvider(t *testing.T) {
    var user *User

    verifier := MessageVerifier{}

    // 1. Map test descriptions to message producer functions (handlers)
    functionMappings := MessageHandlers{
        "a user event": func([]ProviderStateV3) (interface{}, error) {
            if user != nil {
                return user, nil
            } else {
                return ProviderStateV3Response{
                    "message": "not found",
                }, nil
            }
        },
    }

  // 2. Setup any required states for the handlers
    stateMappings := StateHandlers{
        "User with id 127 exists": func(setup bool, s ProviderStateV3) (ProviderStateV3Response, error) {
            if setup {
                user = &User{
                    ID:       127,
                    Name:     "Billy",
                    Date:     "2020-01-01",
                    LastName: "Sampson",
                }
            }

            return ProviderStateV3Response{"id": user.ID}, nil
        },
    }

    // V3. erify the Provider with local Pact Files
    verifier.Verify(t, VerifyMessageRequest{
        VerifyRequest: VerifyRequest{
            PactFiles:     []string{filepath.ToSlash(fmt.Sprintf("%s/V3MessageConsumer-V3MessageProvider.json", pactDir))},
            StateHandlers: stateMappings,
        },
        MessageHandlers: functionMappings,
    })
}

but I cannot find the definition of MessageVerifier and ProviderStateV3Response. I searched the pact - go project through the code - search function and found that no code defined MessageVerifier. Is there something wrong?

Actual behaviour

Please help me provide an example of testing Kafka in Golang.

Steps to reproduce

Provide a repository, gist or reproducable code snippet so that we can test the problem. You may also want to adapt one of the examples in the repository to demonstrate the problem.

Relevent log files

Please ensure you set logging to DEBUG and attach any relevant log files here (or link from a gist).

@mefellows
Copy link
Member

Looks like the docs have drifted, here is an example: https://github.com/pact-foundation/pact-go/blob/master/examples/consumer_v3_test.go#L92

@mefellows mefellows added documentation Indicates a need for improvements or additions to documentation help wanted Indicates that a maintainer wants help on an issue or pull request good first issue Indicates a good issue for first-time contributors labels Dec 9, 2024
@XuNeal
Copy link
Author

XuNeal commented Dec 10, 2024

so cool. it works now

@XuNeal XuNeal closed this as completed Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Indicates a need for improvements or additions to documentation good first issue Indicates a good issue for first-time contributors help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants