MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / runOnDeckQueries

Function runOnDeckQueries

examples/ondeck/mysql/db_test.go:27–141  ·  view source on GitHub ↗
(t *testing.T, q *Queries)

Source from the content-addressed store, hash-verified

25}
26
27func runOnDeckQueries(t *testing.T, q *Queries) {
28 ctx := context.Background()
29
30 err := q.CreateCity(ctx, CreateCityParams{
31 Slug: "san-francisco",
32 Name: "San Francisco",
33 })
34 if err != nil {
35 t.Fatal(err)
36 }
37
38 city, err := q.GetCity(ctx, "san-francisco")
39 if err != nil {
40 t.Fatal(err)
41 }
42
43 venueResult, err := q.CreateVenue(ctx, CreateVenueParams{
44 Slug: "the-fillmore",
45 Name: "The Fillmore",
46 City: city.Slug,
47 SpotifyPlaylist: "spotify:uri",
48 Status: VenueStatusOpen,
49 Statuses: join(string(VenueStatusOpen), string(VenueStatusClosed)),
50 Tags: join("rock", "punk"),
51 })
52 if err != nil {
53 t.Fatal(err)
54 }
55 venueID, err := venueResult.LastInsertId()
56 if err != nil {
57 t.Fatal(err)
58 }
59
60 venue, err := q.GetVenue(ctx, GetVenueParams{
61 Slug: "the-fillmore",
62 City: city.Slug,
63 })
64 if err != nil {
65 t.Fatal(err)
66 }
67
68 if diff := cmp.Diff(venue.ID, uint64(venueID)); diff != "" {
69 t.Errorf("venue ID mismatch:\n%s", diff)
70 }
71
72 {
73 actual, err := q.VenueCountByCity(ctx)
74 if err != nil {
75 t.Error(err)
76 }
77 if diff := cmp.Diff(actual, []VenueCountByCityRow{
78 {city.Slug, int64(1)},
79 }); diff != "" {
80 t.Errorf("venue count mismatch:\n%s", diff)
81 }
82 }
83
84 {

Callers 2

TestPreparedFunction · 0.70
TestQueriesFunction · 0.70

Calls 12

joinFunction · 0.70
CreateCityMethod · 0.65
GetCityMethod · 0.65
CreateVenueMethod · 0.65
GetVenueMethod · 0.65
VenueCountByCityMethod · 0.65
ListCitiesMethod · 0.65
ListVenuesMethod · 0.65
UpdateCityNameMethod · 0.65
UpdateVenueNameMethod · 0.65
DeleteVenueMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected