| 131 | } |
| 132 | |
| 133 | func 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 | |
| 158 | func TestUpdate(t *testing.T) { |
| 159 | stool := newStool() |