Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐘 Test on PG 11 and 12 #401

Merged
merged 3 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ name: CI
on: [push, pull_request]
env:
go-version: '1.14.x'
postgis-version: '2.5'
jobs:
test:
name: Test
strategy:
matrix:
pg-version: ['10', '11']
pg-version: ['11', '12']
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -19,26 +20,32 @@ jobs:
redis version: '5'

- name: Install PostgreSQL
uses: nyaruka/postgis-action@v1.0.0
uses: nyaruka/postgis-action@v2
with:
postgresql version: ${{ matrix.pg-version }}
postgis version: ${{ env.postgis-version }}
postgresql password: temba

- name: Install Linux packages
run: sudo apt install -y --no-install-recommends postgresql-client

- name: Initialize database
# we create our test database with a different user so that we can drop everything owned by this user between tests
run: |
psql -h localhost -U postgres -c "CREATE USER mailroom_test PASSWORD 'temba';"
psql -h localhost -U postgres -c "ALTER ROLE mailroom_test WITH SUPERUSER;"
psql -h localhost -U postgres -c "CREATE DATABASE mailroom_test;"
export PGPASSWORD=temba
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker image with postgres is now postgis:postgis instead of mdillon:postgis and it seems this new one doesn't set POSTGRES_HOST_AUTH_METHOD=trust so you need to set a password for the superuser account and then set it here as an env for psql to use.

psql -h localhost -U postgres --no-password -c "CREATE USER mailroom_test PASSWORD 'temba';"
psql -h localhost -U postgres --no-password -c "ALTER ROLE mailroom_test WITH SUPERUSER;"
psql -h localhost -U postgres --no-password -c "CREATE DATABASE mailroom_test;"

- name: Install Go
uses: actions/setup-go@v1
with:
go-version: ${{ env.go-version }}

- name: Run tests
run: go test -p=1 -coverprofile=coverage.text -covermode=atomic ./...
run: |
export PGPASSWORD=temba
go test -p=1 -coverprofile=coverage.text -covermode=atomic ./...

- name: Upload coverage
if: success()
Expand Down
3 changes: 3 additions & 0 deletions core/models/channel_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ WHERE
cc.channel_id = $1 AND
cc.connection_type = $2 AND
cc.external_id = $3
ORDER BY
cc.id DESC
LIMIT 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicpottier TestTwilioIVR was failing for PG 12 but after much debugging and thinking oh crap we've written some incompatible SQL somewhere it seems it's a case of SelectChannelConnectionByExternalID "always" returning the last of multiple matching connections when tests run under PG 10 and 11, but the first for PG 12. I don't understand the IVR stuff well enough yet to know if it should be matching multiple connections, but this at least makes the assumed behavior explicit.

`

// SelectChannelConnectionByExternalID loads a channel connection by id
Expand Down