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

Function TestPresentBook

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

Source from the content-addressed store, hash-verified

24)
25
26func TestPresentBook(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 testCases := []struct {
31 name string
32 input database.Book
33 expected Book
34 }{
35 {
36 name: "basic book",
37 input: database.Book{
38 Model: database.Model{
39 ID: 1,
40 CreatedAt: createdAt,
41 UpdatedAt: updatedAt,
42 },
43 UUID: "a1b2c3d4-e5f6-4789-a012-3456789abcde",
44 UserID: 42,
45 Label: "JavaScript",
46 USN: 100,
47 },
48 expected: Book{
49 UUID: "a1b2c3d4-e5f6-4789-a012-3456789abcde",
50 USN: 100,
51 CreatedAt: FormatTS(createdAt),
52 UpdatedAt: FormatTS(updatedAt),
53 Label: "JavaScript",
54 },
55 },
56 {
57 name: "book with special characters in label",
58 input: database.Book{
59 Model: database.Model{
60 ID: 2,
61 CreatedAt: createdAt,
62 UpdatedAt: updatedAt,
63 },
64 UUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098",
65 UserID: 99,
66 Label: "C++",
67 USN: 200,
68 },
69 expected: Book{
70 UUID: "f1e2d3c4-b5a6-4987-b654-321fedcba098",
71 USN: 200,
72 CreatedAt: FormatTS(createdAt),
73 UpdatedAt: FormatTS(updatedAt),
74 Label: "C++",
75 },
76 },
77 {
78 name: "book with empty label",
79 input: database.Book{
80 Model: database.Model{
81 ID: 3,
82 CreatedAt: createdAt,
83 UpdatedAt: updatedAt,

Callers

nothing calls this directly

Calls 3

EqualFunction · 0.92
FormatTSFunction · 0.85
PresentBookFunction · 0.85

Tested by

no test coverage detected