Skip to content

Commit

Permalink
added a rough testcase that assures that migrations don't fail withou…
Browse files Browse the repository at this point in the history
…t us noticing
  • Loading branch information
CommanderStorm committed Oct 10, 2023
1 parent c947adc commit 263ccda
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
25 changes: 24 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,32 @@ jobs:
- name: run tests
run: go test -v ./...
working-directory: ./server
test_migrations:
runs-on: ubuntu-latest
services:
mariadb:
image: bitnami/mariadb:latest
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: super_secret_pa$$w0rd
MARIADB_DATABASE: campus_db
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache-dependency-path: |
server/go.sum
- name: run migration
run: go run migrate.go
working-directory: ./server
env:
DB_DSN: root:super_secret_pa$$w0rd@tcp(db:3306)/campus_db?charset=utf8mb4&parseTime=True&loc=Local
ENVIRONMENT: dev
build:
runs-on: ubuntu-latest
needs: [test]
needs: [test, test_migrations]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
11 changes: 11 additions & 0 deletions server/migrate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
log "github.com/sirupsen/logrus"
)

func main() {
if db := setupDB(); db != nil {
log.Fatal("db is nil. How did this happen?")
}
}

0 comments on commit 263ccda

Please sign in to comment.