MCPcopy Index your code
hub / github.com/coder/envbox / TestDocker

Function TestDocker

cli/docker_test.go:34–742  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32)
33
34func TestDocker(t *testing.T) {
35 t.Parallel()
36
37 // Test the basic use case. This test doesn't test much beyond
38 // establishing that the framework is returning a default
39 // successful test. This makes it easier for individual tests
40 // to test various criteria of the command without extensive
41 // setup.
42 t.Run("OK", func(t *testing.T) {
43 t.Parallel()
44
45 ctx, cmd := clitest.New(t, "docker",
46 "--image=ubuntu",
47 "--username=root",
48 "--agent-token=hi",
49 )
50
51 called := make(chan struct{})
52 execer := clitest.Execer(ctx)
53 execer.AddCommands(&xunixfake.FakeCmd{
54 FakeCmd: &testingexec.FakeCmd{
55 Argv: []string{
56 "sysbox-mgr",
57 },
58 },
59 WaitFn: func() error { close(called); select {} }, //nolint:revive
60 })
61
62 err := cmd.ExecuteContext(ctx)
63 <-called
64 require.NoError(t, err)
65 execer.AssertCommandsCalled(t)
66 })
67
68 t.Run("Images", func(t *testing.T) {
69 t.Parallel()
70
71 type testcase struct {
72 name string
73 image string
74 success bool
75 }
76
77 testcases := []testcase{
78 {
79 name: "Repository",
80 image: "ubuntu",
81 success: true,
82 },
83 {
84 name: "RepositoryPath",
85 image: "ubuntu/ubuntu",
86 success: true,
87 },
88
89 {
90 name: "RepositoryLatest",
91 image: "ubuntu:latest",

Callers

nothing calls this directly

Calls 13

NewFunction · 0.92
ExecerFunction · 0.92
DockerClientFunction · 0.92
GetNetLinkFunction · 0.92
FSFunction · 0.92
WithEnvironFnFunction · 0.92
MounterFunction · 0.92
AddCommandsMethod · 0.80
AssertCommandsCalledMethod · 0.80
GetFileOwnerMethod · 0.80
LenMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected