aboutsummaryrefslogtreecommitdiff
path: root/service_report_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'service_report_test.go')
-rw-r--r--service_report_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/service_report_test.go b/service_report_test.go
new file mode 100644
index 0000000..71652f6
--- /dev/null
+++ b/service_report_test.go
@@ -0,0 +1,30 @@
+// SPDX-FileCopyrightText: 2025 M. Shulhan <ms@kilabit.info>
+// SPDX-License-Identifier: GPL-3.0-only
+
+package lilin
+
+import (
+ "testing"
+ "time"
+
+ "git.sr.ht/~shulhan/pakakeh.go/lib/test"
+)
+
+func TestServiceReport_push(t *testing.T) {
+ var svcReport = NewServiceReport(`test`)
+ var x int64
+ for x = 1; x <= historyMax+1; x++ {
+ svcReport.Store(ScanReport{At: time.Unix(x, 0)})
+ }
+ test.Assert(t, `len(History)`, historyKeepSize, len(svcReport.History))
+ test.Assert(t, `cap(History)`, historyMax, cap(svcReport.History))
+
+ var expAtUnix int64 = int64(historyKeepSize + 1)
+ var gotAtUnix = svcReport.History[0].At.Unix()
+ test.Assert(t, `History[0].At`, expAtUnix, gotAtUnix)
+
+ expAtUnix = int64(historyMax) + 1
+ var lastIdx = len(svcReport.History) - 1
+ gotAtUnix = svcReport.History[lastIdx].At.Unix()
+ test.Assert(t, `History[last].At`, expAtUnix, gotAtUnix)
+}