(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestAuthors(t *testing.T) { |
| 16 | ctx := context.Background() |
| 17 | uri := local.PostgreSQL(t, []string{"schema.sql"}) |
| 18 | db, err := pgx.Connect(ctx, uri) |
| 19 | if err != nil { |
| 20 | t.Fatal(err) |
| 21 | } |
| 22 | defer db.Close(ctx) |
| 23 | |
| 24 | q := New(db) |
| 25 | |
| 26 | // list all authors |
| 27 | authors, err := q.ListAuthors(ctx) |
| 28 | if err != nil { |
| 29 | t.Fatal(err) |
| 30 | } |
| 31 | t.Log(authors) |
| 32 | |
| 33 | // create an author |
| 34 | insertedAuthor, err := q.CreateAuthor(ctx, CreateAuthorParams{ |
| 35 | Name: "Brian Kernighan", |
| 36 | Bio: pgtype.Text{String: "Co-author of The C Programming Language and The Go Programming Language", Valid: true}, |
| 37 | }) |
| 38 | if err != nil { |
| 39 | t.Fatal(err) |
| 40 | } |
| 41 | t.Log(insertedAuthor) |
| 42 | |
| 43 | // get the author we just inserted |
| 44 | fetchedAuthor, err := q.GetAuthor(ctx, insertedAuthor.ID) |
| 45 | if err != nil { |
| 46 | t.Fatal(err) |
| 47 | } |
| 48 | t.Log(fetchedAuthor) |
| 49 | } |
nothing calls this directly
no test coverage detected