Skip to content

Commit

Permalink
Run db integration tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
m.kindritskiy committed Sep 15, 2024
1 parent 93d7555 commit 712a307
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ jobs:
- name: Run unit tests
run: tox run -- --cov-report=term

test-db:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Lets
uses: lets-cli/[email protected]
with:
version: latest
- name: Test database integration
run: timeout 600 lets test-pg

federation-test:
runs-on: ubuntu-latest
steps:
Expand Down
20 changes: 9 additions & 11 deletions hiku/sources/aiopg.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ def in_impl(
def select_expr(
self, fields_: List[Field], ids: Iterable
) -> Tuple[Select, Callable]:
visited = set()
columns = []
query_columns = []
for f in fields_:
column = self.from_clause.c[f.name]
columns.append(column)

if f.name not in visited and column != self.primary_key:
visited.add(f.name)
query_columns.append(column)
result_columns = [self.from_clause.c[f.name] for f in fields_]
# aiopg requires unique columns to be passed to select,
# otherwise it will raise an error
query_columns = [
column
for f in _uniq_fields(fields_)
if (column := self.from_clause.c[f.name]) != self.primary_key
]

expr = (
sqlalchemy.select(
Expand All @@ -58,7 +56,7 @@ def select_expr(

def result_proc(rows: List[_sa.Row]) -> List:
rows_map = {
row[self.primary_key]: [row[c] for c in columns]
row[self.primary_key]: [row[c] for c in result_columns]
for row in map(_sa._process_result_row, rows)
}

Expand Down
2 changes: 1 addition & 1 deletion lets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ commands:
test-pg:
description: Run tests with pg
depends: [_build-tests]
cmd: [docker-compose, run, --rm, test-pg]
cmd: [docker compose, run, --rm, test-pg]

test-tox:
description: Run tests using tox
Expand Down

0 comments on commit 712a307

Please sign in to comment.