Skip to content

Commit

Permalink
chore: align readme - prior tests dont have token
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Feb 2, 2024
1 parent 43819e1 commit 14ab6d3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ Let us add Pact to the project and write a consumer pact test for the `GET /user
AddInteraction().
Given("User sally exists").
UponReceiving("A request to login with user 'sally'").
WithRequestPathMatcher("GET", Regex("/users/"+strconv.Itoa(id), "/users/[0-9]+"), func(b *consumer.V2RequestBuilder) {
b.Header("Authorization", Like("Bearer 2019-01-01"))
}).
WithRequestPathMatcher("GET", Regex("/users/"+strconv.Itoa(id), "/users/[0-9]+")).
WillRespondWith(200, func(b *consumer.V2ResponseBuilder) {
b.BodyMatch(model.User{}).
Header("Content-Type", Term("application/json", `application\/json`)).
Expand All @@ -188,7 +186,7 @@ Let us add Pact to the project and write a consumer pact test for the `GET /user
}

// // Execute the API client
user, err := client.WithToken("2019-01-01").GetUser(id)
user, err := client.GetUser(id)

// // Assert basic fact
if user.ID != id {
Expand Down Expand Up @@ -313,9 +311,7 @@ Let's write a test for this scenario, and then generate an updated pact file.
AddInteraction().
Given("User sally does not exist").
UponReceiving("A request to login with user 'sally'").
WithRequestPathMatcher("GET", Regex("/user/"+strconv.Itoa(id), "/user/[0-9]+"), func(b *consumer.V2RequestBuilder) {
b.Header("Authorization", Like("Bearer 2019-01-01"))
}).
WithRequestPathMatcher("GET", Regex("/user/"+strconv.Itoa(id), "/user/[0-9]+")).
WillRespondWith(404, func(b *consumer.V2ResponseBuilder) {
b.Header("Content-Type", Term("application/json", `application\/json`)).
Header("X-Api-Correlation-Id", Like("100"))
Expand All @@ -332,7 +328,7 @@ Let's write a test for this scenario, and then generate an updated pact file.
}

// // Execute the API client
_, err := client.WithToken("2019-01-01").GetUser(id)
_, err := client.GetUser(id)
assert.Equal(t, ErrNotFound, err)
return nil
})
Expand Down

0 comments on commit 14ab6d3

Please sign in to comment.