MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestFaultyDoubleRunWait

Function TestFaultyDoubleRunWait

mod/tigron/internal/com/command_test.go:41–65  ·  view source on GitHub ↗

Testing faulty code (double run, etc.)

(t *testing.T)

Source from the content-addressed store, hash-verified

39// Testing faulty code (double run, etc.)
40
41func TestFaultyDoubleRunWait(t *testing.T) {
42 // Double run returns an error on the second run, but Wait will still work properly
43 t.Parallel()
44
45 command := &com.Command{
46 Binary: "printf",
47 Args: []string{"one"},
48 Timeout: time.Second,
49 }
50
51 err := command.Run(context.WithValue(context.Background(), com.LoggerKey, t))
52
53 assertive.ErrorIsNil(t, err, "Err")
54
55 err = command.Run(context.WithValue(context.Background(), com.LoggerKey, t))
56
57 assertive.ErrorIs(t, err, com.ErrExecAlreadyStarted, "Err")
58
59 res, err := command.Wait()
60
61 assertive.ErrorIsNil(t, err, "Err")
62 assertive.IsEqual(t, expect.ExitCodeSuccess, res.ExitCode, "ExitCode")
63 assertive.IsEqual(t, "one", res.Stdout, "Stdout")
64 assertive.IsEqual(t, "", res.Stderr, "Stderr")
65}
66
67func TestFaultyRunDoubleWait(t *testing.T) {
68 // Double wait returns an error on the second wait, but also returns the existing result

Callers

nothing calls this directly

Calls 3

RunMethod · 0.95
WaitMethod · 0.95
BackgroundMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…