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.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/service_report_test.go b/service_report_test.go
index 350c7f3..74cf214 100644
--- a/service_report_test.go
+++ b/service_report_test.go
@@ -4,6 +4,7 @@
package lilin
import (
+ "bytes"
"os"
"testing"
"time"
@@ -33,6 +34,11 @@ func TestServiceReport_Store(t *testing.T) {
for x = 1; x <= historyMax+1; x++ {
svcReport.Store(ScanReport{At: time.Unix(x, 0)})
}
+ err = svcReport.Close()
+ if err != nil {
+ t.Fatal(err)
+ }
+
test.Assert(t, `len(History)`, historyKeepSize, len(svcReport.History))
test.Assert(t, `cap(History)`, historyMax, cap(svcReport.History))
@@ -44,4 +50,12 @@ func TestServiceReport_Store(t *testing.T) {
var lastIdx = len(svcReport.History) - 1
gotAtUnix = svcReport.History[lastIdx].At.Unix()
test.Assert(t, `History[last].At`, expAtUnix, gotAtUnix)
+
+ var logcontent []byte
+ logcontent, err = os.ReadFile(svcReport.logPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var lines = bytes.Split(logcontent, []byte("\n"))
+ test.Assert(t, `log lines length`, historyMax+2, len(lines))
}