ipn/ipnlocal: make tests pass when offline

Updates #cleanup

Signed-off-by: Maisem Ali <maisem@tailscale.com>
pull/8815/head
Maisem Ali 10 months ago committed by Maisem Ali
parent 25a7204bb4
commit 82454b57dd

@ -8,6 +8,7 @@ import (
"encoding/base64"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"log"
@ -64,6 +65,7 @@ import (
"tailscale.com/types/dnstype"
"tailscale.com/types/empty"
"tailscale.com/types/key"
"tailscale.com/types/lazy"
"tailscale.com/types/logger"
"tailscale.com/types/logid"
"tailscale.com/types/netmap"
@ -91,6 +93,14 @@ import (
"tailscale.com/wgengine/wgcfg/nmcfg"
)
var lazyInTest lazy.SyncValue[bool]
func inTest() bool {
return lazyInTest.Get(func() bool {
return flag.Lookup("test.v") != nil
})
}
var controlDebugFlags = getControlDebugFlags()
func getControlDebugFlags() []string {
@ -496,7 +506,7 @@ func (b *LocalBackend) maybePauseControlClientLocked() {
return
}
networkUp := b.prevIfState.AnyInterfaceUp()
b.cc.SetPaused((b.state == ipn.Stopped && b.netMap != nil) || !networkUp)
b.cc.SetPaused((b.state == ipn.Stopped && b.netMap != nil) || (!networkUp && !inTest()))
}
// linkChange is our network monitor callback, called whenever the network changes.

Loading…
Cancel
Save