-
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.
test: test http-requests via intellij http-client and run in github
action
- Loading branch information
Showing
8 changed files
with
120 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: http-test.yml | ||
on: | ||
push: | ||
branches: | ||
- "*" | ||
|
||
jobs: | ||
HTTP-Tests: | ||
permissions: | ||
contents: read | ||
actions: read | ||
checks: write | ||
runs-on: ubuntu-latest | ||
services: | ||
db: | ||
image: postgres:16 | ||
env: | ||
POSTGRES_PASSWORD: "changeme" | ||
POSTGRES_USER: "godrink" | ||
POSTGRES_DB: "godrink" | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- pgdata:/var/lib/postgresql/data | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
- name: Setup Go | ||
uses: actions/[email protected] | ||
- name: Run Go-Drink | ||
env: | ||
GODRINK_DB: postgresql://godrink:changeme@localhost:5432/godrink?sslmode=disable | ||
run: "go run . &" | ||
- name: Execute HTTP requests | ||
run: ./http-test/test.sh | ||
timeout-minutes: 3 | ||
- name: Publish Test Report | ||
uses: mikepenz/action-junit-report@v4 | ||
if: success() || failure() # always run even if the previous step fails | ||
with: | ||
detailed_summary: true | ||
include_passed: true | ||
require_passed_tests: true | ||
update_check: true | ||
report_paths: ./http-test-reports/report.xml | ||
- name: Upload Test results | ||
uses: actions/[email protected] | ||
with: | ||
name: http-test-reports | ||
path: ./http-test-reports/report.xml |
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,3 +1,4 @@ | ||
.idea | ||
go-drink.iml | ||
go-drink | ||
go-drink | ||
http-test-reports/ |
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,19 @@ | ||
GET {{godrink_url}}/items | ||
|
||
> {% | ||
client.test("returns 200", () => { | ||
client.assert(response.status === 200) | ||
}) | ||
|
||
client.test("returns json", () => { | ||
client.assert(response.contentType.mimeType === "application/json") | ||
}) | ||
|
||
client.test("returns utf-8", () => { | ||
client.assert(response.contentType.charset === "utf-8" || response.contentType.charset.length === 0) | ||
}) | ||
|
||
client.test("returns empty array", () => { | ||
client.assert(response.body.length === 0) | ||
}) | ||
%} |
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,19 @@ | ||
GET {{godrink_url}}/users/noauth | ||
|
||
> {% | ||
client.test("returns 200", () => { | ||
client.assert(response.status === 200) | ||
}) | ||
|
||
client.test("returns json", () => { | ||
client.assert(response.contentType.mimeType === "application/json") | ||
}) | ||
|
||
client.test("returns utf-8", () => { | ||
client.assert(response.contentType.charset === "utf-8" || response.contentType.charset.length === 0) | ||
}) | ||
|
||
client.test("returns empty array", () => { | ||
client.assert(response.body.length === 0) | ||
}) | ||
%} |
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,6 @@ | ||
{ | ||
"dev": { | ||
"godrink_url": "http://localhost:8080" | ||
} | ||
} | ||
|
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,12 @@ | ||
POST {{godrink_url}}/logout | ||
|
||
> {% | ||
client.test("returns 200", ()=>{ | ||
client.assert(response.status === 200) | ||
}) | ||
|
||
client.test("no body", () => { | ||
client.assert(!response.body) | ||
}) | ||
|
||
%} |
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,10 @@ | ||
#!/bin/bash | ||
|
||
set +e | ||
while | ||
(exec 6<>/dev/tcp/localhost/8080) 2>/dev/null | ||
[ $? == 1 ] | ||
do echo Waiting for Go Drink; sleep 1; done | ||
set -e | ||
|
||
docker run --network="host" --rm -v $PWD:/workdir jetbrains/intellij-http-client -e dev -v http-test/http-client.env.json -r http-test-reports http-test/*.http |