Some checks failed
check / check (push) Failing after 1m21s
Changes the Go module path from `git.eeqj.de/sneak/neoirc` to `sneak.berlin/go/neoirc`. All occurrences updated: - `go.mod` module directive - All Go import paths across 35 `.go` files (107 import statements) - All JSON schema `$id` URIs across 30 `.json` files in `schema/` No functional changes — this is a pure rename of the module path. `docker build .` passes clean (formatting, linting, all tests, binary build). closes #98 Co-authored-by: clawbot <clawbot@users.noreply.git.eeqj.de> Reviewed-on: #99 Co-authored-by: clawbot <clawbot@noreply.example.org> Co-committed-by: clawbot <clawbot@noreply.example.org>
118 lines
1.9 KiB
Go
118 lines
1.9 KiB
Go
package stats_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"sneak.berlin/go/neoirc/internal/stats"
|
|
)
|
|
|
|
func TestNew(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tracker := stats.New()
|
|
if tracker == nil {
|
|
t.Fatal("expected non-nil tracker")
|
|
}
|
|
|
|
if tracker.ConnectionsSinceBoot() != 0 {
|
|
t.Errorf(
|
|
"expected 0 connections, got %d",
|
|
tracker.ConnectionsSinceBoot(),
|
|
)
|
|
}
|
|
|
|
if tracker.SessionsSinceBoot() != 0 {
|
|
t.Errorf(
|
|
"expected 0 sessions, got %d",
|
|
tracker.SessionsSinceBoot(),
|
|
)
|
|
}
|
|
|
|
if tracker.MessagesSinceBoot() != 0 {
|
|
t.Errorf(
|
|
"expected 0 messages, got %d",
|
|
tracker.MessagesSinceBoot(),
|
|
)
|
|
}
|
|
}
|
|
|
|
func TestIncrConnections(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tracker := stats.New()
|
|
|
|
tracker.IncrConnections()
|
|
tracker.IncrConnections()
|
|
tracker.IncrConnections()
|
|
|
|
got := tracker.ConnectionsSinceBoot()
|
|
if got != 3 {
|
|
t.Errorf(
|
|
"expected 3 connections, got %d", got,
|
|
)
|
|
}
|
|
}
|
|
|
|
func TestIncrSessions(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tracker := stats.New()
|
|
|
|
tracker.IncrSessions()
|
|
tracker.IncrSessions()
|
|
|
|
got := tracker.SessionsSinceBoot()
|
|
if got != 2 {
|
|
t.Errorf(
|
|
"expected 2 sessions, got %d", got,
|
|
)
|
|
}
|
|
}
|
|
|
|
func TestIncrMessages(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tracker := stats.New()
|
|
|
|
tracker.IncrMessages()
|
|
|
|
got := tracker.MessagesSinceBoot()
|
|
if got != 1 {
|
|
t.Errorf(
|
|
"expected 1 message, got %d", got,
|
|
)
|
|
}
|
|
}
|
|
|
|
func TestCountersAreIndependent(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tracker := stats.New()
|
|
|
|
tracker.IncrConnections()
|
|
tracker.IncrSessions()
|
|
tracker.IncrMessages()
|
|
tracker.IncrMessages()
|
|
|
|
if tracker.ConnectionsSinceBoot() != 1 {
|
|
t.Errorf(
|
|
"expected 1 connection, got %d",
|
|
tracker.ConnectionsSinceBoot(),
|
|
)
|
|
}
|
|
|
|
if tracker.SessionsSinceBoot() != 1 {
|
|
t.Errorf(
|
|
"expected 1 session, got %d",
|
|
tracker.SessionsSinceBoot(),
|
|
)
|
|
}
|
|
|
|
if tracker.MessagesSinceBoot() != 2 {
|
|
t.Errorf(
|
|
"expected 2 messages, got %d",
|
|
tracker.MessagesSinceBoot(),
|
|
)
|
|
}
|
|
}
|