Skip to content

chore: avoid dbmock test errors in dbgen #10923

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

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions coderd/database/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
go run golang.org/x/tools/cmd/goimports@latest -w queries.sql.go

go run ../../scripts/dbgen
# This will error if a view is broken.
go test -run=TestViewSubset
# This will error if a view is broken. This is in it's own package to avoid
# stuff like dbmock breaking builds if it's out of date from the interface.
go test ./gentest
)
8 changes: 8 additions & 0 deletions coderd/database/gentest/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Package gentest contains tests that are run at db generate time. These tests
// need to exist in their own package to avoid importing stuff that gets
// generated after the DB.
//
// E.g. if we put these tests in coderd/database, then we'd be importing dbmock
// which is generated after the DB and can cause type problems when building
// the tests.
package gentest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package database_test
package gentest_test

import (
"reflect"
Expand Down