Skip to content

Commit

Permalink
Update unit & venom tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CristyNel committed Oct 2, 2024
1 parent e852bdc commit b35cf5b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 14 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,28 @@ jobs:
go-version: 1.23.1

- name: verify go installation
run: echo -e '\033[94;1m * * * 🔗 pwd = '$(pwd) '\n\033[94;1m * * * 🐹 Go version' && go version
run: |
echo -e '\033[94;1m * * * 🔗 pwd = '$(pwd) '\n\033[94;1m * * * 🐹 Go version'
go version
- name: install dependencies
working-directory: ./api
run: echo -e '\033[94;1m * * * 🔗 pwd = '$(pwd) '\n\033[94;1m * * * 🧰 Install dependencies' && go mod tidy
run: |
echo -e '\033[94;1m * * * 🔗 pwd = '$(pwd) '\n\033[94;1m * * * 🧰 Install dependencies'
go mod tidy
- name: install wkhtmltopdf
run: |
echo -e '\033[94;1m * * * 🎨 Installing wkhtmltopdf'
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:apt-fast/stable
sudo apt-get install -y wkhtmltopdf
- name: run unit tests
working-directory: ./api
run: echo -e '\033[94;1m * * * 🔗 pwd = '$(pwd) '\n\033[94;1m * * * ⭐ Run unit tests' && go test -v ./...
run: |
echo -e '\033[94;1m * * * 🔗 pwd = '$(pwd) '\n\033[94;1m * * * ⭐ Run unit tests'
go test -v ./...
- name: cache go modules
uses: actions/cache@v4
Expand Down
37 changes: 26 additions & 11 deletions .github/workflows/venom-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,46 @@ jobs:
- name: checkout code
uses: actions/checkout@v4

- name: Set up Go environment
uses: actions/setup-go@v4
- name: set up go
uses: actions/setup-go@v5
with:
go-version: "1.23.1"
go-version: 1.23.1

- name: Verify go installation
run: |
echo -e '\033[94;1m * * * 🔗 pwd = '$(pwd) '\n\033[94;1m * * * 🐹 Go version'
go version
- name: Install dependencies
working-directory: ./api
run: |
cd api
go mod download
echo -e '\033[94;1m * * * 🔗 pwd = '$(pwd) '\n\033[94;1m * * * 🧰 Install dependencies'
go mod tidy
- name: install docker compose
- name: Install docker compose
run: |
echo -e '\033[94;1m * * * 🐳 Installing docker compose'
sudo curl -L "https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Set up Docker Compose
run: |
echo -e '\033[94;1m * * * 🛠️ Set up Docker'
docker-compose -f ./docker-compose.yml up -d
- name: install venom
- name: Install venom
run: |
echo -e '\033[94;1m * * * 🐍 Installing venom'
curl https://github.com/ovh/venom/releases/download/v1.0.1/venom.linux-amd64 -L -o /usr/local/bin/venom
chmod +x /usr/local/bin/venom
- name: run e2e tests
run: venom run api/e2etests.yaml
- name: stop docker compose
run: docker-compose -f ./docker-compose.yml down --volumes
- name: Run e2e tests
working-directory: ./api/tests
run: |
echo -e '\033[94;1m * * * 🔗 pwd = '$(pwd) '\n\033[94;1m * * * ⭐ Run e2e tests'
venom run e2etests.yml
- name: Stop docker compose
run: |
echo -e '\033[94;1m * * * ❌ Stop docker compose'
docker-compose -f ./docker-compose.yml down --volumes
35 changes: 35 additions & 0 deletions api/tests/e2etests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: API E2E Tests

vars:
sql.url: ""
api.url: ""

testcases:
- name: Fetch DB Container IP
steps:
- type: exec
script: docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cv_db-container
assertions:
- result.code ShouldEqual 0
extract:
sql.url: result.systemout

- name: Fetch API Container IP
steps:
- type: exec
script: docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cv_api-container
assertions:
- result.code ShouldEqual 0
extract:
api.url: result.systemout

- name: DeleteUser
steps:
- type: http
method: DELETE
url: "http://{{.api.url}}:8080/user/5"
headers:
Content-Type: application/json
assertions:
- result.statuscode ShouldEqual 204

0 comments on commit b35cf5b

Please sign in to comment.