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

Function TestPresentNote

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

Source from the content-addressed store, hash-verified

24)
25
26func TestPresentNote(t *testing.T) {
27 createdAt := time.Date(2025, 1, 15, 10, 30, 45, 123456789, time.UTC)
28 updatedAt := time.Date(2025, 2, 20, 14, 45, 30, 987654321, time.UTC)
29
30 input := database.Note{
31 Model: database.Model{
32 ID: 1,
33 CreatedAt: createdAt,
34 UpdatedAt: updatedAt,
35 },
36 UUID: "a1b2c3d4-e5f6-4789-a012-3456789abcde",
37 UserID: 42,
38 BookUUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098",
39 Body: "Test note content",
40 AddedOn: 1234567890,
41 USN: 100,
42 Book: database.Book{
43 UUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098",
44 Label: "JavaScript",
45 },
46 User: database.User{
47 UUID: "9a8b7c6d-5e4f-4321-9876-543210fedcba",
48 },
49 }
50
51 got := PresentNote(input)
52
53 assert.Equal(t, got.UUID, "a1b2c3d4-e5f6-4789-a012-3456789abcde", "UUID mismatch")
54 assert.Equal(t, got.Body, "Test note content", "Body mismatch")
55 assert.Equal(t, got.AddedOn, int64(1234567890), "AddedOn mismatch")
56 assert.Equal(t, got.USN, 100, "USN mismatch")
57 assert.Equal(t, got.CreatedAt, FormatTS(createdAt), "CreatedAt mismatch")
58 assert.Equal(t, got.UpdatedAt, FormatTS(updatedAt), "UpdatedAt mismatch")
59 assert.Equal(t, got.Book.UUID, "f1e2d3c4-b5a6-4987-b654-321fedcba098", "Book UUID mismatch")
60 assert.Equal(t, got.Book.Label, "JavaScript", "Book Label mismatch")
61 assert.Equal(t, got.User.UUID, "9a8b7c6d-5e4f-4321-9876-543210fedcba", "User UUID mismatch")
62}
63
64func TestPresentNotes(t *testing.T) {
65 createdAt1 := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)

Callers

nothing calls this directly

Calls 3

EqualFunction · 0.92
PresentNoteFunction · 0.85
FormatTSFunction · 0.85

Tested by

no test coverage detected