mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-10-12 01:58:46 +02:00
The journal records the network state of the host and each change of that state. The support team reads one file to see the interfaces, the routes, the resolvers, and the recoveries around an incident. The same file shows the health of the query path. A change that touches only AirDrop or virtual interfaces runs no DNS work.
38 lines
855 B
Go
38 lines
855 B
Go
package ctrld
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
// resetIPv6Probe clears the one-time IPv6 probe. Test only: the process runs
|
|
// the probe once, so a test cannot see it without this reset.
|
|
func resetIPv6Probe(t *testing.T) {
|
|
t.Helper()
|
|
reset := func() {
|
|
hasIPv6Once = sync.Once{}
|
|
ipv6Available.Store(false)
|
|
}
|
|
reset()
|
|
t.Cleanup(reset)
|
|
}
|
|
|
|
func TestHasIPv6KeepsTheProbeThenTakesTheStoredFlag(t *testing.T) {
|
|
resetIPv6Probe(t)
|
|
|
|
probed := HasIPv6()
|
|
if got := HasIPv6(); got != probed {
|
|
t.Fatalf("HasIPv6 = %v on the second call, want the probe value %v", got, probed)
|
|
}
|
|
|
|
SetIPv6Available(!probed)
|
|
if got := HasIPv6(); got == probed {
|
|
t.Fatalf("HasIPv6 = %v after SetIPv6Available(%v), want the stored value", got, !probed)
|
|
}
|
|
|
|
SetIPv6Available(false)
|
|
if HasIPv6() {
|
|
t.Fatal("HasIPv6 = true after SetIPv6Available(false), want false")
|
|
}
|
|
}
|