MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestInitCommandContextUsesTimeout

Function TestInitCommandContextUsesTimeout

cmd/root_test.go:286–303  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

284}
285
286func TestInitCommandContextUsesTimeout(t *testing.T) {
287 t.Cleanup(finishCommandContext)
288
289 cmd := &cobra.Command{Use: "test"}
290 cmd.Flags().Duration("timeout", 50*time.Millisecond, "")
291
292 if err := initCommandContext(cmd); err != nil {
293 t.Fatalf("initCommandContext error: %v", err)
294 }
295
296 deadline, ok := currentContext().Deadline()
297 if !ok {
298 t.Fatal("currentContext deadline missing")
299 }
300 if remaining := time.Until(deadline); remaining <= 0 || remaining > time.Second {
301 t.Fatalf("deadline remaining = %v, want positive timeout near 50ms", remaining)
302 }
303}
304
305func TestInitCommandContextRejectsNegativeTimeout(t *testing.T) {
306 t.Cleanup(finishCommandContext)

Callers

nothing calls this directly

Calls 2

initCommandContextFunction · 0.85
currentContextFunction · 0.85

Tested by

no test coverage detected