| 123456789101112131415161718192021222324252627 |
- package fwh_pro
- import (
- "testing"
- "fwh-toolbox-server/domain"
- )
- func TestLatestMatchingEmsLogRecordIgnoresPreviousCalls(t *testing.T) {
- records := []domain.EmsLogRecordInfo{
- {Id: 12, LogTime: "2026-09-20", CodeType: 4},
- {Id: 18, LogTime: "2026-09-21", CodeType: 4},
- {Id: 15, LogTime: "2026-09-20", CodeType: 7},
- {Id: 16, LogTime: "2026-09-20", CodeType: 4},
- }
- baseline := latestMatchingEmsLogRecord(records, "2026-09-20", 4, -1)
- if baseline == nil || baseline.Id != 16 {
- t.Fatalf("baseline = %+v, want ID 16", baseline)
- }
- if got := latestMatchingEmsLogRecord(records, "2026-09-20", 4, baseline.Id); got != nil {
- t.Fatalf("previous call matched as new: %+v", got)
- }
- records = append(records, domain.EmsLogRecordInfo{Id: 19, LogTime: "2026-09-20", CodeType: 4})
- if got := latestMatchingEmsLogRecord(records, "2026-09-20", 4, baseline.Id); got == nil || got.Id != 19 {
- t.Fatalf("new call record = %+v, want ID 19", got)
- }
- }
|