-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rework tests to explicit given-when-then pattern (#86)
- Loading branch information
1 parent
579b4a7
commit e712789
Showing
9 changed files
with
65 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"uuid": "UUID", | ||
"email": "EMAIL", | ||
"fullName": "FULL_NAME", | ||
"startDate": "START_DATE", | ||
"endDate": "END_DATE", | ||
"campsiteId": "1" | ||
"campsiteId": "1", | ||
"active": "true" | ||
} |
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 |
---|---|---|
|
@@ -6,22 +6,19 @@ start_date="$1" | |
end_date="$2" | ||
base_url="$3" | ||
|
||
payload1=$(< concurrent-test/booking-payload.json sed -e "s/UUID/$(uuidgen)/g" \ | ||
| sed -e "s/EMAIL/[email protected]/g" \ | ||
payload1=$(< concurrent-test/booking-payload.json sed -e "s/EMAIL/[email protected]/g" \ | ||
| sed -e "s/FULL_NAME/John Smith 1/g" \ | ||
| sed -e "s/START_DATE/${start_date}/g" \ | ||
| sed -e "s/END_DATE/${end_date}/g") | ||
printf "Create payload 1: %s\n" "$payload1" | ||
|
||
payload2=$(< concurrent-test/booking-payload.json sed -e "s/UUID/$(uuidgen)/g" \ | ||
| sed -e "s/EMAIL/[email protected]/g" \ | ||
| sed -e "s/FULL_NAME/John Smith /g" \ | ||
payload2=$(< concurrent-test/booking-payload.json sed -e "s/EMAIL/[email protected]/g" \ | ||
| sed -e "s/FULL_NAME/John Smith 2/g" \ | ||
| sed -e "s/START_DATE/${start_date}/g" \ | ||
| sed -e "s/END_DATE/${end_date}/g") | ||
printf "Create payload 2: %s\n" "$payload2" | ||
|
||
payload3=$(< concurrent-test/booking-payload.json sed -e "s/UUID/$(uuidgen)/g" \ | ||
| sed -e "s/EMAIL/[email protected]/g" \ | ||
payload3=$(< concurrent-test/booking-payload.json sed -e "s/EMAIL/[email protected]/g" \ | ||
| sed -e "s/FULL_NAME/John Smith 3/g" \ | ||
| sed -e "s/START_DATE/${start_date}/g" \ | ||
| sed -e "s/END_DATE/${end_date}/g") | ||
|
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 |
---|---|---|
|
@@ -5,10 +5,8 @@ set -e | |
start_date="$1" | ||
end_date="$2" | ||
base_url="$3" | ||
uuid="$(uuidgen)" | ||
|
||
payload=$(< concurrent-test/booking-payload.json sed -e "s/UUID/$uuid/g" \ | ||
| sed -e "s/EMAIL/[email protected]/g" \ | ||
payload=$(< concurrent-test/booking-payload.json sed -e "s/EMAIL/[email protected]/g" \ | ||
| sed -e "s/FULL_NAME/John Smith 1/g" \ | ||
| sed -e "s/START_DATE/$start_date/g" \ | ||
| sed -e "s/END_DATE/$end_date/g") | ||
|
@@ -17,6 +15,9 @@ printf "Create payload: %s\n" "$payload" | |
response=$(curl -X POST -H "Content-Type: application/json" -d "$payload" "$base_url"/v2/booking) | ||
printf "Response: %s\n" "$response" | ||
|
||
uuid=$(echo "$response" | sed -En 's/.*"uuid":"([^"]*).*/\1/p') | ||
printf "UUID: %s\n" "$uuid" | ||
|
||
payload1=${response//\"campsiteId\"\:1/\"campsiteId\"\:2} | ||
printf "Update payload 1: %s\n" "$payload1" | ||
|
||
|
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,8 +1,10 @@ | ||
package com.kiroule.campsite.booking.api; | ||
|
||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; | ||
|
||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@SpringBootTest(webEnvironment = RANDOM_PORT) | ||
@ActiveProfiles("in-memory-db") | ||
public abstract class BaseIT {} |
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