Clean project layout and fix release workflow
Some checks failed
build-windows-exe / build (push) Failing after 1m13s
Some checks failed
build-windows-exe / build (push) Failing after 1m13s
This commit is contained in:
26
internal/app/join_leave_events_test.go
Normal file
26
internal/app/join_leave_events_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestDeduplicateJoinLeaveEventsIgnoresRepeatedReplays(t *testing.T) {
|
||||
at := time.Date(2026, 7, 1, 1, 23, 45, 0, time.FixedZone("JST", 9*60*60))
|
||||
events := []JoinLeaveEvent{
|
||||
{At: at, Kind: "join", Name: "Alice", Count: 10},
|
||||
{At: at, Kind: "join", Name: "Alice", Count: 11},
|
||||
{At: at.Add(5 * time.Second), Kind: "leave", Name: "Alice", Count: 9},
|
||||
}
|
||||
|
||||
got := dedupeJoinLeaveEvents(events)
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("expected 2 unique events, got %d: %#v", len(got), got)
|
||||
}
|
||||
if got[0].Count != 10 {
|
||||
t.Fatalf("expected first event to remain stable, got %#v", got[0])
|
||||
}
|
||||
if got[1].Kind != "leave" {
|
||||
t.Fatalf("expected leave event to remain, got %#v", got[1])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user