| 24 | ) |
| 25 | |
| 26 | func TestNewNote(t *testing.T) { |
| 27 | testCases := []struct { |
| 28 | uuid string |
| 29 | bookUUID string |
| 30 | body string |
| 31 | addedOn int64 |
| 32 | editedOn int64 |
| 33 | usn int |
| 34 | deleted bool |
| 35 | dirty bool |
| 36 | }{ |
| 37 | { |
| 38 | uuid: "n1-uuid", |
| 39 | bookUUID: "b1-uuid", |
| 40 | body: "n1-body", |
| 41 | addedOn: 1542058875, |
| 42 | editedOn: 0, |
| 43 | usn: 0, |
| 44 | deleted: false, |
| 45 | dirty: false, |
| 46 | }, |
| 47 | { |
| 48 | uuid: "n2-uuid", |
| 49 | bookUUID: "b2-uuid", |
| 50 | body: "n2-body", |
| 51 | addedOn: 1542058875, |
| 52 | editedOn: 1542058876, |
| 53 | usn: 1008, |
| 54 | deleted: true, |
| 55 | dirty: true, |
| 56 | }, |
| 57 | } |
| 58 | |
| 59 | for idx, tc := range testCases { |
| 60 | got := NewNote(tc.uuid, tc.bookUUID, tc.body, tc.addedOn, tc.editedOn, tc.usn, tc.deleted, tc.dirty) |
| 61 | |
| 62 | assert.Equal(t, got.UUID, tc.uuid, fmt.Sprintf("UUID mismatch for test case %d", idx)) |
| 63 | assert.Equal(t, got.BookUUID, tc.bookUUID, fmt.Sprintf("BookUUID mismatch for test case %d", idx)) |
| 64 | assert.Equal(t, got.Body, tc.body, fmt.Sprintf("Body mismatch for test case %d", idx)) |
| 65 | assert.Equal(t, got.AddedOn, tc.addedOn, fmt.Sprintf("AddedOn mismatch for test case %d", idx)) |
| 66 | assert.Equal(t, got.EditedOn, tc.editedOn, fmt.Sprintf("EditedOn mismatch for test case %d", idx)) |
| 67 | assert.Equal(t, got.USN, tc.usn, fmt.Sprintf("USN mismatch for test case %d", idx)) |
| 68 | assert.Equal(t, got.Deleted, tc.deleted, fmt.Sprintf("Deleted mismatch for test case %d", idx)) |
| 69 | assert.Equal(t, got.Dirty, tc.dirty, fmt.Sprintf("Dirty mismatch for test case %d", idx)) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | func TestNoteInsert(t *testing.T) { |
| 74 | testCases := []struct { |