File tree 2 files changed +12
-9
lines changed
2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,11 @@ func (dcl *DockerCLILister) List(ctx context.Context) (codersdk.WorkspaceAgentLi
59
59
}
60
60
61
61
dockerPsStderr := strings .TrimSpace (stderrBuf .String ())
62
+ if len (ids ) == 0 {
63
+ return codersdk.WorkspaceAgentListContainersResponse {
64
+ Warnings : []string {dockerPsStderr },
65
+ }, nil
66
+ }
62
67
63
68
// now we can get the detailed information for each container
64
69
// Run `docker inspect` on each container ID
Original file line number Diff line number Diff line change @@ -2,8 +2,7 @@ package agentcontainers
2
2
3
3
import (
4
4
"fmt"
5
- "os/exec"
6
- "runtime"
5
+ "os"
7
6
"strconv"
8
7
"strings"
9
8
"testing"
@@ -27,15 +26,14 @@ import (
27
26
// dockerCLIContainerLister.List method. It starts a container with a known
28
27
// label, lists the containers, and verifies that the expected container is
29
28
// returned. The container is deleted after the test is complete.
29
+ // As this test creates containers, it is skipped by default.
30
+ // It can be run manually as follows:
31
+ //
32
+ // CODER_TEST_USE_DOCKER=1 go test ./agent/agentcontainers -run TestDockerCLIContainerLister
30
33
func TestDockerCLIContainerLister (t * testing.T ) {
31
34
t .Parallel ()
32
- if runtime .GOOS != "linux" {
33
- t .Skip ("creating containers on non-linux runners is slow and flaky" )
34
- }
35
-
36
- // Conditionally skip if Docker is not available.
37
- if _ , err := exec .LookPath ("docker" ); err != nil {
38
- t .Skip ("docker not found in PATH" )
35
+ if ctud , ok := os .LookupEnv ("CODER_TEST_USE_DOCKER" ); ! ok || ctud != "1" {
36
+ t .Skip ("Set CODER_TEST_USE_DOCKER=1 to run this test" )
39
37
}
40
38
41
39
pool , err := dockertest .NewPool ("" )
You can’t perform that action at this time.
0 commit comments