Reuse a single long-poll HTTP client instead of creating one per Events() call (~every 30s). Make TLS skip-verify configurable via syncthing_insecure_tls. Log previously swallowed config errors. Add unit tests for all monitor trackers, config, and state logic. Add CI workflow (vet, golangci-lint, govulncheck, go test -race). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
29 lines
531 B
Go
29 lines
531 B
Go
package monitor
|
|
|
|
import "testing"
|
|
|
|
func TestConflictTracker_IncrementAndCount(t *testing.T) {
|
|
ct := NewConflictTracker()
|
|
if ct.Count() != 0 {
|
|
t.Fatalf("initial count should be 0, got %d", ct.Count())
|
|
}
|
|
|
|
ct.Increment()
|
|
ct.Increment()
|
|
ct.Increment()
|
|
|
|
if ct.Count() != 3 {
|
|
t.Errorf("expected 3, got %d", ct.Count())
|
|
}
|
|
}
|
|
|
|
func TestConflictTracker_SetCount(t *testing.T) {
|
|
ct := NewConflictTracker()
|
|
ct.Increment()
|
|
ct.SetCount(42)
|
|
|
|
if ct.Count() != 42 {
|
|
t.Errorf("expected 42 after SetCount, got %d", ct.Count())
|
|
}
|
|
}
|