(t *testing.T)
| 68 | } |
| 69 | |
| 70 | func TestRecordPostScan(t *testing.T) { |
| 71 | t.Parallel() |
| 72 | |
| 73 | collection := core.NewBaseCollection("test_collection") |
| 74 | collection.Fields.Add(&core.TextField{Name: "test"}) |
| 75 | |
| 76 | m := core.NewRecord(collection) |
| 77 | |
| 78 | // calling PostScan without id |
| 79 | err := m.PostScan() |
| 80 | if err == nil { |
| 81 | t.Fatal("Expected PostScan id error, got nil") |
| 82 | } |
| 83 | |
| 84 | m.Id = "test_id" |
| 85 | m.Set("test", "abc") |
| 86 | |
| 87 | if v := m.IsNew(); v != true { |
| 88 | t.Fatalf("[before PostScan] Expected IsNew %v, got %v", true, v) |
| 89 | } |
| 90 | if v := m.Original().PK(); v != "" { |
| 91 | t.Fatalf("[before PostScan] Expected the original PK to be empty string, got %v", v) |
| 92 | } |
| 93 | if v := m.Original().Get("test"); v != "" { |
| 94 | t.Fatalf("[before PostScan] Expected the original 'test' field to be empty string, got %v", v) |
| 95 | } |
| 96 | |
| 97 | err = m.PostScan() |
| 98 | if err != nil { |
| 99 | t.Fatalf("Expected PostScan nil error, got %v", err) |
| 100 | } |
| 101 | |
| 102 | if v := m.IsNew(); v != false { |
| 103 | t.Fatalf("[after PostScan] Expected IsNew %v, got %v", false, v) |
| 104 | } |
| 105 | if v := m.Original().PK(); v != "test_id" { |
| 106 | t.Fatalf("[after PostScan] Expected the original PK to be %q, got %v", "test_id", v) |
| 107 | } |
| 108 | if v := m.Original().Get("test"); v != "abc" { |
| 109 | t.Fatalf("[after PostScan] Expected the original 'test' field to be %q, got %v", "abc", v) |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | func TestRecordHookTags(t *testing.T) { |
| 114 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…