(t *testing.T)
| 557 | } |
| 558 | |
| 559 | func TestCountParamsNotZero(t *testing.T) { |
| 560 | db, err := sql.Open("sqlite3", fmt.Sprintf("file:%s?mode=rw&cache=shared&_journal_mode=WAL", testDbPath)) |
| 561 | if err != nil { |
| 562 | t.Fatalf("Should open testDbPath (%s) just fine", testDbPath) |
| 563 | } |
| 564 | defer db.Close() |
| 565 | |
| 566 | db.SetMaxOpenConns(1) |
| 567 | |
| 568 | for i := 1; i <= 10; i++ { |
| 569 | t.Run(fmt.Sprintf("TestCount%dParams", i), func(t *testing.T) { |
| 570 | where := make([]string, i) |
| 571 | for j := 0; j < i; j++ { |
| 572 | where[j] = "ip = ?" |
| 573 | } |
| 574 | |
| 575 | queryStmt, err := db.Prepare(fmt.Sprintf("select * from ip_dns where %s", strings.Join(where, " AND "))) |
| 576 | if err != nil { |
| 577 | t.Fatal("Should prepare query just fine") |
| 578 | } |
| 579 | |
| 580 | count, err := countParams(queryStmt) |
| 581 | if err != nil { |
| 582 | t.Fatal("Shouldn't throw an error") |
| 583 | } |
| 584 | if count != i { |
| 585 | t.Fatalf("Should return %d", i) |
| 586 | } |
| 587 | }) |
| 588 | } |
| 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)) |
nothing calls this directly
no test coverage detected