Skip to content

Commit 54f0fda

Browse files
committed
Use new go:build and add test target to mage
1 parent 2bb1195 commit 54f0fda

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

.github/workflows/go.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ jobs:
3232
go-version: 1.24 # TODO: matrix
3333

3434
- name: Test
35-
run: go test -v -race ./...
35+
uses: magefile/mage-action@6f50bbb8ea47d56e62dee92392788acbc8192d0b # v3.1.0
36+
with:
37+
version: latest
38+
args: test
3639

3740
check:
3841
runs-on: ubuntu-latest

fakedb_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ type fakeConn struct {
194194
called bool // nolint:structcheck // ignore unused warning, it is accessed via reflection
195195
rowsCloseCalled bool
196196
stmt driver.Stmt
197+
queryStmt driver.StmtQueryContext
197198
tx driver.Tx
198199
}
199200

@@ -221,17 +222,12 @@ func (c *fakeConn) Close() error { return nil }
221222

222223
func (c *fakeConn) Begin() (driver.Tx, error) { return c.tx, nil }
223224

224-
func (c *fakeConn) QueryContext(_ context.Context, _ string, nvs []driver.NamedValue) (driver.Rows, error) {
225-
if c.stmt == nil {
225+
func (c *fakeConn) QueryContext(ctx context.Context, _ string, nvs []driver.NamedValue) (driver.Rows, error) {
226+
if c.queryStmt == nil {
226227
return &fakeRows{con: c}, nil
227228
}
228229

229-
var args []driver.Value
230-
for _, nv := range nvs {
231-
args = append(args, nv.Value)
232-
}
233-
234-
return c.stmt.Query(args)
230+
return c.queryStmt.QueryContext(ctx, nvs)
235231
}
236232

237233
func (c *fakeConnWithCheckNamedValue) CheckNamedValue(_ *driver.NamedValue) (err error) {

magefiles/mage.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ func Lint(ctx context.Context) error {
1414
args := []string{"run", "--config", ".golangci.yml"}
1515
return sh.RunV("golangci-lint", args...)
1616
}
17+
18+
// Test runs the tests
19+
func Test(ctx context.Context) error {
20+
args := []string{"test", "-v", "-race", "./..."}
21+
return sh.RunV("go", args...)
22+
}

rows_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func TestRowsNext(t *testing.T) {
109109
stmt := fakeStmt{
110110
rows: rows,
111111
}
112-
con.stmt = stmt
112+
con.queryStmt = stmt
113113
driverName := driverName(t)
114114
interceptor := rowsNextInterceptor{}
115115

@@ -199,7 +199,7 @@ func TestRows_LikePGX(t *testing.T) {
199199
stmt := fakeStmt{
200200
rows: rows,
201201
}
202-
con.stmt = stmt
202+
con.queryStmt = stmt
203203
driverName := driverName(t)
204204
interceptor := rowsNextInterceptor{}
205205

tools/rows_picker_gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build ignore
1+
//go:build ignore
22

33
package main
44

0 commit comments

Comments
 (0)