This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contract-tests: Update package names and workaround pact-foundation/p…
…act-go#108 issue.
- Loading branch information
Showing
7 changed files
with
61 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nsumer/fabric8auth/verify_interactions.go → ...acts/consumer_test/verify_interactions.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fabric8auth | ||
package consumer | ||
|
||
import ( | ||
"fmt" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package contracts | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/pact-foundation/pact-go/dsl" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// PactDir returns a path to the directory to store pact files (taken from PACT_DIR env variable) | ||
func PactDir() string { | ||
return os.Getenv("PACT_DIR") | ||
} | ||
|
||
// PactFile returns a path to the generated pact file | ||
func PactFile(pactConsumer string, pactProvider string) string { | ||
return fmt.Sprintf("%s/%s-%s.json", PactDir(), strings.ToLower(pactConsumer), strings.ToLower(pactProvider)) | ||
} | ||
|
||
// CheckErrorAndCleanPact is a workaround for the https://github.com/pact-foundation/pact-go/issues/108 issue | ||
// by manually clearing the interactions from pact and the mock service. | ||
func CheckErrorAndCleanPact(t *testing.T, pact *dsl.Pact, err1 error) { | ||
if err1 != nil { | ||
pact.Interactions = make([]*dsl.Interaction, 0) | ||
mockServer := &dsl.MockService{ | ||
BaseURL: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port), | ||
Consumer: pact.Consumer, | ||
Provider: pact.Provider, | ||
} | ||
err2 := mockServer.DeleteInteractions() | ||
require.NoError(t, err2) | ||
} | ||
require.NoError(t, err1) | ||
} |