| 53 | } |
| 54 | |
| 55 | func TestBind(t *testing.T) { |
| 56 | store := new(DbRecorder) |
| 57 | |
| 58 | stool := newStool() |
| 59 | store.Bind("test_table", stool) |
| 60 | |
| 61 | if store.table != "test_table" { |
| 62 | t.Errorf("Failed to get table name.") |
| 63 | } |
| 64 | |
| 65 | if len(store.fields) != 5 { |
| 66 | t.Errorf("Expected 5 fields, got %d: %+v", len(store.fields), store.fields) |
| 67 | } |
| 68 | |
| 69 | keyCount := 0 |
| 70 | for _, f := range store.fields { |
| 71 | if f.isKey { |
| 72 | keyCount++ |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | if keyCount != 2 { |
| 77 | t.Errorf("Expected two keys.") |
| 78 | } |
| 79 | |
| 80 | if len(store.Key()) != 2 { |
| 81 | t.Errorf("Wrong number of keys.") |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | func TestLoad(t *testing.T) { |
| 86 | stool := newStool() |