TestQuerySourceGetter covers the session accessor a future compute meter reads: unset defaults to "standard", a SET value round-trips, and reset to empty falls back to the default.
(t *testing.T)
| 13 | |
| 14 | // TestQuerySourceGetter covers the session accessor the compute meter reads: |
| 15 | // unset defaults to "standard", a SET value round-trips, and reset to empty |
| 16 | // falls back to the default. Callers of setQuerySource pass already-validated |
| 17 | // canonical values (the transpiler / startup-option validation reject anything |
| 18 | // outside {standard, endpoints} with 22023 before the setter is reached). |
| 19 | func TestQuerySourceGetter(t *testing.T) { |
| 20 | c := &clientConn{} |
| 21 | |
| 22 | // Unset → default "standard" (never an error for a missing value). |
| 23 | if got := c.QuerySource(); got != "standard" { |
| 24 | t.Fatalf("unset QuerySource() = %q, want %q", got, "standard") |
| 25 | } |
| 26 | if got := c.QuerySource(); got != defaultQuerySource { |
| 27 | t.Fatalf("unset QuerySource() = %q, want defaultQuerySource %q", got, defaultQuerySource) |
| 28 | } |
| 29 | |
| 30 | // SET → value round-trips. |
| 31 | c.setQuerySource("endpoints") |
| 32 | if got := c.QuerySource(); got != "endpoints" { |
| 33 | t.Fatalf("after set, QuerySource() = %q, want %q", got, "endpoints") |
| 34 | } |
| 35 | |
| 36 | // RESET / empty → back to default. |
| 37 | c.setQuerySource("") |
| 38 | if got := c.QuerySource(); got != "standard" { |
| 39 | t.Fatalf("after reset, QuerySource() = %q, want %q", got, "standard") |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // TestQuerySourceStartupOption asserts a `-c duckgres.query_source=...` startup |
| 44 | // option is parsed into the map ParseStartupOptions returns and applied to the |
| 45 | // session by applyStartupQuerySource, with the same validation as SET: |
nothing calls this directly
no test coverage detected