MCPcopy
hub / github.com/lxc/incus / TestSelectObjects_Error

Function TestSelectObjects_Error

internal/server/db/query/objects_test.go:15–42  ·  view source on GitHub ↗

Exercise possible failure modes.

(t *testing.T)

Source from the content-addressed store, hash-verified

13
14// Exercise possible failure modes.
15func TestSelectObjects_Error(t *testing.T) {
16 cases := []struct {
17 dest query.Dest
18 query string
19 error string
20 }{
21 {
22 func(scan func(dest ...any) error) error {
23 var row any
24 return scan(row)
25 },
26 "SELECT id, name FROM test",
27 "sql: expected 2 destination arguments in Scan, not 1",
28 },
29 }
30
31 for _, c := range cases {
32 t.Run(c.query, func(t *testing.T) {
33 tx := newTxForObjects(t)
34
35 stmt, err := tx.Prepare(c.query)
36 require.NoError(t, err)
37
38 err = query.SelectObjects(context.TODO(), stmt, c.dest)
39 assert.EqualError(t, err, c.error)
40 })
41 }
42}
43
44// Scan rows yielded by the query.
45func TestSelectObjects(t *testing.T) {

Callers

nothing calls this directly

Calls 5

SelectObjectsFunction · 0.92
newTxForObjectsFunction · 0.85
PrepareMethod · 0.65
scanFunction · 0.50
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…