MCPcopy Index your code
hub / github.com/dnote/dnote / TestPresentNotes

Function TestPresentNotes

pkg/server/presenters/note_test.go:64–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestPresentNotes(t *testing.T) {
65 createdAt1 := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
66 updatedAt1 := time.Date(2025, 1, 2, 0, 0, 0, 0, time.UTC)
67 createdAt2 := time.Date(2025, 2, 1, 0, 0, 0, 0, time.UTC)
68 updatedAt2 := time.Date(2025, 2, 2, 0, 0, 0, 0, time.UTC)
69
70 input := []database.Note{
71 {
72 Model: database.Model{
73 ID: 1,
74 CreatedAt: createdAt1,
75 UpdatedAt: updatedAt1,
76 },
77 UUID: "a1b2c3d4-e5f6-4789-a012-3456789abcde",
78 UserID: 1,
79 BookUUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098",
80 Body: "First note",
81 AddedOn: 1000000000,
82 USN: 10,
83 Book: database.Book{
84 UUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098",
85 Label: "Go",
86 },
87 User: database.User{
88 UUID: "9a8b7c6d-5e4f-4321-9876-543210fedcba",
89 },
90 },
91 {
92 Model: database.Model{
93 ID: 2,
94 CreatedAt: createdAt2,
95 UpdatedAt: updatedAt2,
96 },
97 UUID: "12345678-90ab-4cde-8901-234567890abc",
98 UserID: 1,
99 BookUUID: "abcdef01-2345-4678-9abc-def012345678",
100 Body: "Second note",
101 AddedOn: 2000000000,
102 USN: 20,
103 Book: database.Book{
104 UUID: "abcdef01-2345-4678-9abc-def012345678",
105 Label: "Python",
106 },
107 User: database.User{
108 UUID: "9a8b7c6d-5e4f-4321-9876-543210fedcba",
109 },
110 },
111 }
112
113 got := PresentNotes(input)
114
115 assert.Equal(t, len(got), 2, "Length mismatch")
116 assert.Equal(t, got[0].UUID, "a1b2c3d4-e5f6-4789-a012-3456789abcde", "Note 0 UUID mismatch")
117 assert.Equal(t, got[0].Body, "First note", "Note 0 Body mismatch")
118 assert.Equal(t, got[1].UUID, "12345678-90ab-4cde-8901-234567890abc", "Note 1 UUID mismatch")
119 assert.Equal(t, got[1].Body, "Second note", "Note 1 Body mismatch")
120}

Callers

nothing calls this directly

Calls 2

EqualFunction · 0.92
PresentNotesFunction · 0.85

Tested by

no test coverage detected