Skip to content

Commit

Permalink
Add workflows for unit and integration tests (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
oskirby authored Sep 10, 2024
1 parent 9a9d7ba commit 6306dcb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Tests
on:
push:
branches:
- main
pull_request:
branches:
- main

# Restrict tests to the most recent commit.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Run unit tests
shell: bash
run: make test

integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Pull autograph image
shell: bash
run: docker pull mozilla/autograph

- name: Build autograph-edge
shell: bash
run: docker compose build

- name: Sign test APKs and XPIs and verify the APK
shell: bash
run: docker compose run test
5 changes: 4 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ func Test_validateBaseURL(t *testing.T) {
}

func Test_preparedServer(t *testing.T) {
// For the purpose of testing - ensure we're using IPv4.
conf.BaseURL = "http://127.0.0.1:8000/"

testServer := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, client")
}))
Expand Down Expand Up @@ -421,7 +424,7 @@ func Test_preparedServer(t *testing.T) {
"X-Content-Type-Options": []string{"nosniff"},
"Strict-Transport-Security": []string{"max-age=31536000;"},
},
expectedBody: `{"status":false,"checks":{"check_autograph_heartbeat":false},"details":"failed to request autograph heartbeat from http://localhost:8000/__heartbeat__: Get \"http://localhost:8000/__heartbeat__\": dial tcp 127.0.0.1:8000: connect: connection refused"}`,
expectedBody: `{"status":false,"checks":{"check_autograph_heartbeat":false},"details":"failed to request autograph heartbeat from http://127.0.0.1:8000/__heartbeat__: Get \"http://127.0.0.1:8000/__heartbeat__\": dial tcp 127.0.0.1:8000: connect: connection refused"}`,
},
{
name: "test GET /sign path method not allowed",
Expand Down

0 comments on commit 6306dcb

Please sign in to comment.