forked from pact-foundation/pact-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,67 @@ | ||
package consumer | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
// "errors" | ||
// "testing" | ||
|
||
"github.com/pact-foundation/pact-go/v2/matchers" | ||
"github.com/pact-foundation/pact-go/v2/models" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
// "github.com/pact-foundation/pact-go/v2/matchers" | ||
// "github.com/pact-foundation/pact-go/v2/models" | ||
// "github.com/stretchr/testify/assert" | ||
|
||
func TestInteraction(t *testing.T) { | ||
// func TestInteraction(t *testing.T) { | ||
|
||
t.Run("validateMatchers for V2 Specification", func(t *testing.T) { | ||
// t.Run("validateMatchers for V2 Specification", func(t *testing.T) { | ||
|
||
testCases := []struct { | ||
description string | ||
test interface{} | ||
want error | ||
}{ | ||
{ | ||
description: "string body should return nil", | ||
test: "I'm a string", | ||
want: nil, | ||
}, | ||
{ | ||
description: "boolean body should return nil", | ||
test: true, | ||
want: nil, | ||
}, | ||
{ | ||
description: "numeric body should return nil", | ||
test: 27, | ||
want: nil, | ||
}, | ||
{ | ||
description: "v3 matches should error", | ||
test: map[string]interface{}{ | ||
"dateTime": matchers.Regex("2020-01-01", "[0-9\\-]+"), | ||
"name": matchers.S("Billy"), | ||
"superstring": matchers.Includes("foo"), | ||
"nested": map[string]matchers.Matcher{ | ||
"val": matchers.Includes("val"), | ||
}, | ||
}, | ||
want: errors.New("test error"), | ||
}, | ||
{ | ||
description: "v2 matches should no terror", | ||
test: map[string]interface{}{ | ||
"dateTime": matchers.Regex("2020-01-01", "[0-9\\-]+"), | ||
"name": matchers.S("Billy"), | ||
"nested": map[string]matchers.Matcher{ | ||
"val": matchers.Regex("val", ".*"), | ||
}, | ||
}, | ||
want: nil, | ||
}, | ||
} | ||
// testCases := []struct { | ||
// description string | ||
// test interface{} | ||
// want error | ||
// }{ | ||
// { | ||
// description: "string body should return nil", | ||
// test: "I'm a string", | ||
// want: nil, | ||
// }, | ||
// { | ||
// description: "boolean body should return nil", | ||
// test: true, | ||
// want: nil, | ||
// }, | ||
// { | ||
// description: "numeric body should return nil", | ||
// test: 27, | ||
// want: nil, | ||
// }, | ||
// { | ||
// description: "v3 matches should error", | ||
// test: map[string]interface{}{ | ||
// "dateTime": matchers.Regex("2020-01-01", "[0-9\\-]+"), | ||
// "name": matchers.S("Billy"), | ||
// "superstring": matchers.Includes("foo"), | ||
// "nested": map[string]matchers.Matcher{ | ||
// "val": matchers.Includes("val"), | ||
// }, | ||
// }, | ||
// want: errors.New("test error"), | ||
// }, | ||
// { | ||
// description: "v2 matches should no terror", | ||
// test: map[string]interface{}{ | ||
// "dateTime": matchers.Regex("2020-01-01", "[0-9\\-]+"), | ||
// "name": matchers.S("Billy"), | ||
// "nested": map[string]matchers.Matcher{ | ||
// "val": matchers.Regex("val", ".*"), | ||
// }, | ||
// }, | ||
// want: nil, | ||
// }, | ||
// } | ||
|
||
for _, test := range testCases { | ||
if test.want != nil { | ||
assert.Error(t, validateMatchers(models.V2, test.test), test.description) | ||
} else { | ||
assert.NoError(t, validateMatchers(models.V2, test.test), test.description) | ||
} | ||
} | ||
}) | ||
} | ||
// for _, test := range testCases { | ||
// if test.want != nil { | ||
// assert.Error(t, validateMatchers(models.V2, test.test), test.description) | ||
// } else { | ||
// assert.NoError(t, validateMatchers(models.V2, test.test), test.description) | ||
// } | ||
// } | ||
// }) | ||
// } |
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