(t *testing.T)
| 589 | } |
| 590 | |
| 591 | func TestCountParamsHandleDBError(t *testing.T) { |
| 592 | db, err := sql.Open("sqlite3", fmt.Sprintf("file:%s?mode=rw&cache=shared&_journal_mode=WAL", testDbPath)) |
| 593 | if err != nil { |
| 594 | t.Fatalf("Should open testDbPath (%s) just fine", testDbPath) |
| 595 | } |
| 596 | |
| 597 | db.SetMaxOpenConns(1) |
| 598 | |
| 599 | queryStmt, err := db.Prepare("select * from ip_dns") |
| 600 | if err != nil { |
| 601 | t.Fatal("Should prepare query just fine") |
| 602 | } |
| 603 | |
| 604 | db.Close() |
| 605 | |
| 606 | count, err := countParams(queryStmt) |
| 607 | if count != -1 { |
| 608 | t.Fatal("Count should equal -1") |
| 609 | } |
| 610 | if err == nil || !strings.Contains(err.Error(), "Cannot extract params count from query error") { |
| 611 | t.Fatalf(`Should throw a 'syntax error' error: %v`, err) |
| 612 | } |
| 613 | } |
nothing calls this directly
no test coverage detected