MCPcopy Index your code
hub / github.com/Masterminds/structable / TestLoad

Function TestLoad

structable_test.go:85–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

83}
84
85func TestLoad(t *testing.T) {
86 stool := newStool()
87 db := &DBStub{}
88 //db, builder := squirrelFixture()
89
90 r := New(db, "mysql").Bind("test_table", stool)
91
92 if err := r.Load(); err != nil {
93 t.Errorf("Error running query: %s", err)
94 }
95
96 expect := "SELECT number_of_legs, material, color FROM test_table WHERE id = ? AND id_two = ?"
97 if db.LastQueryRowSql != expect {
98 t.Errorf("Unexpected SQL: %s", db.LastQueryRowSql)
99 }
100
101 expectargs := []interface{}{1, 2}
102 got := db.LastQueryRowArgs
103 for i, exp := range expectargs {
104 if exp != got[i] {
105 t.Errorf("Surprise! %v doesn't equal %v", exp, got[i])
106 }
107 }
108}
109
110func TestLoadWhere(t *testing.T) {
111 stool := newStool()

Callers

nothing calls this directly

Calls 4

newStoolFunction · 0.85
NewFunction · 0.85
BindMethod · 0.65
LoadMethod · 0.65

Tested by

no test coverage detected