diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1c9e1bd19..928ece2ac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,10 +48,6 @@ jobs: run: | "CGO_LDFLAGS=-L$env:TMP" >> $env:GITHUB_ENV "$env:TMP" >> $env:GITHUB_PATH - - name: Skip Avro plugin & test (windows) - if: matrix.os == 'windows-latest' - run: | - "SKIP_PLUGIN_AVRO=1" >> $env:GITHUB_ENV - name: Test (unit) if: matrix.os != 'ubuntu-latest' run: make test diff --git a/Makefile b/Makefile index 0a6582e20..f9a60549c 100755 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL=$(DOCKER_HOST PLUGIN_PACT_PROTOBUF_VERSION=0.3.15 PLUGIN_PACT_CSV_VERSION=0.0.6 PLUGIN_PACT_MATT_VERSION=0.1.1 -PLUGIN_PACT_AVRO_VERSION=0.0.5 +PLUGIN_PACT_AVRO_VERSION=0.0.6 GO_VERSION?=1.22 ci:: docker deps clean bin test pact @@ -89,12 +89,10 @@ download_plugins: else \ echo "--- 🐿 Pact matt-$(PLUGIN_PACT_MATT_VERSION) already installed"; \ fi; \ - if [ -z $$SKIP_PLUGIN_AVRO ]; then\ - if [ ! -f ~/.pact/plugins/avro-$(PLUGIN_PACT_AVRO_VERSION)/bin/pact-avro-plugin ]; then \ - ~/.pact/bin/pact-plugin-cli -y install https://github.com/austek/pact-avro-plugin/releases/tag/v$(PLUGIN_PACT_AVRO_VERSION); \ - else \ - echo "--- 🐿 Pact avro-$(PLUGIN_PACT_AVRO_VERSION) already installed"; \ - fi; \ + if [ ! -f ~/.pact/plugins/avro-$(PLUGIN_PACT_AVRO_VERSION)/bin/pact-avro-plugin ]; then \ + ~/.pact/bin/pact-plugin-cli -y install https://github.com/austek/pact-avro-plugin/releases/tag/v$(PLUGIN_PACT_AVRO_VERSION); \ + else \ + echo "--- 🐿 Pact avro-$(PLUGIN_PACT_AVRO_VERSION) already installed"; \ fi; \ fi diff --git a/examples/avro/avro_consumer_test.go b/examples/avro/avro_consumer_test.go index 15613893e..6483ee98d 100644 --- a/examples/avro/avro_consumer_test.go +++ b/examples/avro/avro_consumer_test.go @@ -22,18 +22,17 @@ import ( var dir, _ = os.Getwd() func TestAvroHTTP(t *testing.T) { - if os.Getenv("SKIP_PLUGIN_AVRO") != "1" { - mockProvider, err := consumer.NewV4Pact(consumer.MockHTTPProviderConfig{ - Consumer: "AvroConsumer", - Provider: "AvroProvider", - PactDir: filepath.ToSlash(fmt.Sprintf("%s/../pacts", dir)), - }) - assert.NoError(t, err) + mockProvider, err := consumer.NewV4Pact(consumer.MockHTTPProviderConfig{ + Consumer: "AvroConsumer", + Provider: "AvroProvider", + PactDir: filepath.ToSlash(fmt.Sprintf("%s/../pacts", dir)), + }) + assert.NoError(t, err) - dir, _ := os.Getwd() - path := fmt.Sprintf("%s/user.avsc", strings.ReplaceAll(dir, "\\", "/")) + dir, _ := os.Getwd() + path := fmt.Sprintf("%s/user.avsc", strings.ReplaceAll(dir, "\\", "/")) - avroResponse := `{ + avroResponse := `{ "pact:avro": "` + path + `", "pact:record-name": "User", "pact:content-type": "avro/binary", @@ -41,28 +40,28 @@ func TestAvroHTTP(t *testing.T) { "username": "notEmpty('matt')" }` - // Set up our expected interactions. - err = mockProvider. - AddInteraction(). - UponReceiving("A request to do get some Avro stuff"). - UsingPlugin(consumer.PluginConfig{ - Plugin: "avro", - Version: "0.0.5", - }). - WithRequest("GET", "/avro"). - WillRespondWith(200, func(res *consumer.V4InteractionWithPluginResponseBuilder) { - res.PluginContents("avro/binary", avroResponse) - }). - ExecuteTest(t, func(msc consumer.MockServerConfig) error { - resp, err := callServiceHTTP(msc) - - assert.Equal(t, int64(1), resp.ID) - assert.Equal(t, "matt", resp.Username) // ??????! - - return err - }) - assert.NoError(t, err) - } + // Set up our expected interactions. + err = mockProvider. + AddInteraction(). + UponReceiving("A request to do get some Avro stuff"). + UsingPlugin(consumer.PluginConfig{ + Plugin: "avro", + Version: "0.0.6", + }). + WithRequest("GET", "/avro"). + WillRespondWith(200, func(res *consumer.V4InteractionWithPluginResponseBuilder) { + res.PluginContents("avro/binary", avroResponse) + }). + ExecuteTest(t, func(msc consumer.MockServerConfig) error { + resp, err := callServiceHTTP(msc) + + assert.Equal(t, int64(1), resp.ID) + assert.Equal(t, "matt", resp.Username) // ??????! + + return err + }) + assert.NoError(t, err) + } func callServiceHTTP(msc consumer.MockServerConfig) (*User, error) { diff --git a/examples/avro/avro_provider_test.go b/examples/avro/avro_provider_test.go index 38779439c..c7f957436 100644 --- a/examples/avro/avro_provider_test.go +++ b/examples/avro/avro_provider_test.go @@ -21,25 +21,24 @@ var dir, _ = os.Getwd() var pactDir = fmt.Sprintf("%s/../pacts", dir) func TestAvroHTTPProvider(t *testing.T) { - if os.Getenv("SKIP_PLUGIN_AVRO") != "1" { - httpPort, _ := utils.GetFreePort() + httpPort, _ := utils.GetFreePort() - // Start provider API in the background - go startHTTPProvider(httpPort) + // Start provider API in the background + go startHTTPProvider(httpPort) - verifier := provider.NewVerifier() + verifier := provider.NewVerifier() - // Verify the Provider with local Pact Files - err := verifier.VerifyProvider(t, provider.VerifyRequest{ - ProviderBaseURL: fmt.Sprintf("http://127.0.0.1:%d", httpPort), - Provider: "AvroProvider", - PactFiles: []string{ - filepath.ToSlash(fmt.Sprintf("%s/AvroConsumer-AvroProvider.json", pactDir)), - }, - }) + // Verify the Provider with local Pact Files + err := verifier.VerifyProvider(t, provider.VerifyRequest{ + ProviderBaseURL: fmt.Sprintf("http://127.0.0.1:%d", httpPort), + Provider: "AvroProvider", + PactFiles: []string{ + filepath.ToSlash(fmt.Sprintf("%s/AvroConsumer-AvroProvider.json", pactDir)), + }, + }) + + assert.NoError(t, err) - assert.NoError(t, err) - } } func startHTTPProvider(port int) {