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

Function TestInsert

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

Source from the content-addressed store, hash-verified

131}
132
133func TestInsert(t *testing.T) {
134 stool := newStool()
135 db := new(DBStub)
136
137 rec := New(db, "mysql").Bind("test_table", stool)
138
139 if err := rec.Insert(); err != nil {
140 t.Errorf("Failed insert: %s", err)
141 }
142
143 expect := "INSERT INTO test_table (id_two,number_of_legs,material) VALUES (?,?,?)"
144 if db.LastExecSql != expect {
145 t.Errorf("Expected '%s', got '%s'", expect, db.LastExecSql)
146 }
147
148 expectargs := []interface{}{stool.Id2, stool.Legs, stool.Material}
149 gotargs := db.LastExecArgs
150
151 for i := range expectargs {
152 if expectargs[i] != gotargs[i] {
153 t.Errorf("Expected %v, got %v", expectargs[i], gotargs[i])
154 }
155 }
156}
157
158func TestUpdate(t *testing.T) {
159 stool := newStool()

Callers

nothing calls this directly

Calls 4

newStoolFunction · 0.85
NewFunction · 0.85
BindMethod · 0.65
InsertMethod · 0.65

Tested by

no test coverage detected