test_utils.go 312 B

12345678910111213141516171819202122
  1. package db
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/jackc/pgx/v4/pgxpool"
  6. )
  7. func PrepareDatabaseForTesting() *pgxpool.Conn {
  8. fmt.Println("Preparing database for testing")
  9. MigrateDatabase()
  10. conn := GetConnection()
  11. conn.Query(
  12. context.Background(),
  13. "truncate table songs",
  14. )
  15. return conn
  16. }