MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / TestRunBrowserBootstrap_TokenEmpty

Function TestRunBrowserBootstrap_TokenEmpty

internal/cli/bootstrap_test.go:167–182  ·  view source on GitHub ↗

TestRunBrowserBootstrap_TokenEmpty — file exists but is empty (0 bytes or only whitespace). EnsureBootstrapToken would never produce this, but a corrupted file or partial write deserves a clear error rather than silently building a `#token=` URL with an empty token.

(t *testing.T)

Source from the content-addressed store, hash-verified

165// a corrupted file or partial write deserves a clear error rather than
166// silently building a `#token=` URL with an empty token.
167func TestRunBrowserBootstrap_TokenEmpty(t *testing.T) {
168 srv := fakeSessionServer(t, func() SessionResponse {
169 return SessionResponse{SetupRequired: true, SetupMethod: "logs_token"}
170 })
171 cfg := newTestConfig(t, srv.URL)
172 writeBootstrapToken(t, cfg.DataDir, " ")
173
174 client := NewClientFromURL(srv.URL)
175 err := RunBrowserBootstrap(context.Background(), client, cfg, "")
176 if err == nil {
177 t.Fatal("RunBrowserBootstrap returned nil with empty token, want error")
178 }
179 if !strings.Contains(err.Error(), "empty") {
180 t.Errorf("error %q should call out empty token", err.Error())
181 }
182}
183
184// TestRunBrowserBootstrap_LocalCLIMethod — the server failed to provision
185// a bootstrap token (read-only DataDir, etc.) and the bypass flag isn't

Callers

nothing calls this directly

Calls 6

fakeSessionServerFunction · 0.85
writeBootstrapTokenFunction · 0.85
NewClientFromURLFunction · 0.85
RunBrowserBootstrapFunction · 0.85
newTestConfigFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected