ipn/ipnlocal: remove NewLocalBackendWithClientGen

This removes the NewLocalBackendWithClientGen constructor added in
b4d04a065f and instead adds
LocalBackend.SetControlClientGetterForTesting, mirroring
LocalBackend.SetHTTPTestClient. NewLocalBackendWithClientGen was
weird in being exported but taking an unexported type. This was noted
during code review:

https://github.com/tailscale/tailscale/pull/1818#discussion_r623155669

which ended in:

"I'll leave it for y'all to clean up if you find some way to do it elegantly."

This is more idiomatic.

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-04-30 07:23:22 -07:00
parent 0181a4d0ac
commit 544d8d0ab8
2 changed files with 35 additions and 21 deletions

View File

@@ -278,7 +278,11 @@ func TestStateMachine(t *testing.T) {
}
cc := newMockControl()
ccGen := func(opts controlclient.Options) (controlclient.Client, error) {
b, err := NewLocalBackend(logf, "logid", store, e)
if err != nil {
t.Fatalf("NewLocalBackend: %v", err)
}
b.SetControlClientGetterForTesting(func(opts controlclient.Options) (controlclient.Client, error) {
cc.mu.Lock()
cc.opts = opts
cc.logf = opts.Logf
@@ -289,11 +293,7 @@ func TestStateMachine(t *testing.T) {
cc.logf("ccGen: new mockControl.")
cc.called("New")
return cc, nil
}
b, err := NewLocalBackendWithClientGen(logf, "logid", store, e, ccGen)
if err != nil {
t.Fatalf("NewLocalBackend: %v", err)
}
})
notifies := &notifyThrottler{t: t}
notifies.expect(0)