package cameras import ( "log" "testing" ) // The bug this guards: both callers built the Syncer as a struct literal, set // Engine and Cloud, and left Checks and Prober nil. runChecks returns silently // when either is nil - correct for an unclaimed PC - so a camera check // requested at head office was claimed by nobody and sat at "checking..." until // the server released it five minutes later. Nothing logged, on either side. func TestNewWiresEveryHalfOfTheSyncer(t *testing.T) { eng := NewEngineClient("http://127.0.0.1:8010", "u", "p") cloud := NewCloudClient("https://example.invalid", "token") s := New(eng, cloud, log.Default()) if s.Engine == nil || s.Cloud == nil { t.Fatal("configuration half not wired") } // The half that proves a camera works. A Syncer without these is not a // broken Syncer, which is exactly why the omission was invisible. if s.Checks == nil { t.Error("Checks is nil: head office's camera checks would never be claimed") } if s.Prober == nil { t.Error("Prober is nil: a claimed check could never be answered") } }