Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 452668c

Browse files
authored
chore: avoid dbmock test errors in dbgen (#10923)
1 parent 14bd489 commit 452668c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

coderd/database/generate.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
5858
go run golang.org/x/tools/cmd/goimports@latest -w queries.sql.go
5959

6060
go run ../../scripts/dbgen
61-
# This will error if a view is broken.
62-
go test -run=TestViewSubset
61+
# This will error if a view is broken. This is in it's own package to avoid
62+
# stuff like dbmock breaking builds if it's out of date from the interface.
63+
go test ./gentest
6364
)

coderd/database/gentest/doc.go

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Package gentest contains tests that are run at db generate time. These tests
2+
// need to exist in their own package to avoid importing stuff that gets
3+
// generated after the DB.
4+
//
5+
// E.g. if we put these tests in coderd/database, then we'd be importing dbmock
6+
// which is generated after the DB and can cause type problems when building
7+
// the tests.
8+
package gentest

coderd/database/models_test.go renamed to coderd/database/gentest/models_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package database_test
1+
package gentest_test
22

33
import (
44
"reflect"

0 commit comments

Comments
 (0)