fwh_emsLog_test.go 951 B

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