stuff
This commit is contained in:
1 parent
1275e5a821
commit
ff9860023b
3 files changed
+50
-6
No files matched your search
+18
-1
@@ -31,6 +31,23 @@ func TestHandleIndexRendersWatts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatGermanNumber(t *testing.T) {
|
||||
tests := map[int]string{
|
||||
0: "0",
|
||||
12: "12",
|
||||
999: "999",
|
||||
1000: "1.000",
|
||||
10000: "10.000",
|
||||
1234567: "1.234.567",
|
||||
-1000: "-1.000",
|
||||
}
|
||||
for input, want := range tests {
|
||||
if got := formatGermanNumber(input); got != want {
|
||||
t.Fatalf("formatGermanNumber(%d) = %q, want %q", input, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleWriteRequiresSecret(t *testing.T) {
|
||||
srv := &server{secret: "secret", store: &store{}}
|
||||
req := httptest.NewRequest(http.MethodPost, "/write", bytes.NewBufferString(`{"watts":456}`))
|
||||
@@ -116,7 +133,7 @@ func TestBuildHistoryChartRendersPolyline(t *testing.T) {
|
||||
func TestBuildHistoryChartUsesConfiguredMax(t *testing.T) {
|
||||
history := []sample{{at: time.Date(2026, 4, 20, 12, 0, 0, 0, time.UTC), value: 250}}
|
||||
chart := buildHistoryChart(history, 1000)
|
||||
if !strings.Contains(string(chart), "1000 W") {
|
||||
if !strings.Contains(string(chart), "1.000 W") {
|
||||
t.Fatalf("chart did not include configured max: %s", string(chart))
|
||||
}
|
||||
if strings.Contains(string(chart), "250 W") {
|
||||
|
||||
Reference in new issue
Block a user