-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb_test.go
More file actions
97 lines (84 loc) · 1.92 KB
/
Copy pathweb_test.go
File metadata and controls
97 lines (84 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"net/http/httptest"
"strings"
"testing"
"github.com/prairiegroupinc/linearsummarybot/yearmonth"
)
func newMockReport() *Report {
// Create a sample report with a mix of initiatives and orphaned issues
agMVP := &InitiativeData{
Name: "AG MVP",
Fixed: 80,
Planned: 1,
Total: 81,
Issues: []*IssueData{
{
Identifier: "DEV-123",
Title: "Implement feature X",
Points: 5,
Schedule: Fixed,
},
},
}
other := &InitiativeData{
Name: "Other",
Fixed: 1,
Total: 1,
Issues: []*IssueData{
{
Identifier: "DEV-225",
Title: "Refresh page after adding vendible to cart",
Points: 1,
Schedule: Fixed,
},
},
}
month := &MonthData{
Name: "February 2025",
Key: yearmonth.Make(2025, 2),
Initiatives: map[string]*InitiativeData{
"AG MVP": agMVP,
"Other": other,
},
SortedInitiatives: []*InitiativeData{agMVP, other},
Fixed: 81,
Planned: 1,
Total: 82,
}
return &Report{
Months: []*MonthData{month},
}
}
func TestServeSpecificHTMLReport(t *testing.T) {
// Create a mock report
report := newMockReport()
// Create a response recorder
w := httptest.NewRecorder()
// Call the handler
err := serveSpecificHTMLReport(w, report)
if err != nil {
t.Fatalf("Failed to serve HTML report: %v", err)
}
// Check response
response := w.Body.String()
// Basic checks for expected content
expectedStrings := []string{
"February 2025",
"AG MVP",
"DEV-123",
"Implement feature X",
"DEV-225",
"Refresh page after adding vendible to cart",
}
for _, s := range expectedStrings {
if !strings.Contains(response, s) {
t.Errorf("Response missing expected string: %q", s)
}
}
// Check content type
contentType := w.Header().Get("Content-Type")
if contentType != "text/html; charset=utf-8" {
t.Errorf("Wrong content type, got %q, want text/html; charset=utf-8", contentType)
}
}