Skip to content

Commit a5fbf37

Browse files
committed
amend PR comments
1 parent ea0125d commit a5fbf37

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

agent/agentcontainers/containers_dockercli_test.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestIntegrationDockerCLI(t *testing.T) {
6464
arch, err := dcli.DetectArchitecture(ctx, containerName)
6565
require.NoError(t, err, "DetectArchitecture failed")
6666
require.NotEmpty(t, arch, "arch has no content")
67-
require.Equal(t, runtime.GOARCH, arch, "architecture does not match runtime")
67+
require.Equal(t, runtime.GOARCH, arch, "architecture does not match runtime, did you run this test with a remote Docker socket?")
6868

6969
t.Logf("Detected architecture: %s", arch)
7070
})
@@ -92,21 +92,26 @@ func TestIntegrationDockerCLI(t *testing.T) {
9292
t.Parallel()
9393

9494
// Test ExecAs without specifying user (should use container's default).
95-
want := "hello without user"
96-
got, err := dcli.ExecAs(ctx, containerName, "", "echo", want)
95+
want := "root"
96+
got, err := dcli.ExecAs(ctx, containerName, "", "whoami")
9797
require.NoError(t, err, "ExecAs without user should succeed")
9898
require.Equal(t, want, string(got), "ExecAs without user should output expected string")
99-
t.Logf("ExecAs without user output: %s", got)
10099

101-
// Test ExecAs with root user (should convert "root" to "0").
102-
want = "hello as root"
103-
got, err = dcli.ExecAs(ctx, containerName, "root", "echo", want)
100+
// Test ExecAs with numeric UID (non root).
101+
want = "1000"
102+
_, err = dcli.ExecAs(ctx, containerName, want, "whoami")
103+
require.Error(t, err, "ExecAs with UID 1000 should fail as user does not exist in busybox")
104+
require.Contains(t, err.Error(), "whoami: unknown uid 1000", "ExecAs with UID 1000 should return 'unknown uid' error")
105+
106+
// Test ExecAs with root user (should convert "root" to "0", which still outputs root due to passwd).
107+
want = "root"
108+
got, err = dcli.ExecAs(ctx, containerName, "root", "whoami")
104109
require.NoError(t, err, "ExecAs with root user should succeed")
105110
require.Equal(t, want, string(got), "ExecAs with root user should output expected string")
106111

107112
// Test ExecAs with numeric UID.
108-
want = "hello as uid 0"
109-
got, err = dcli.ExecAs(ctx, containerName, "0", "echo", want)
113+
want = "root"
114+
got, err = dcli.ExecAs(ctx, containerName, "0", "whoami")
110115
require.NoError(t, err, "ExecAs with UID 0 should succeed")
111116
require.Equal(t, want, string(got), "ExecAs with UID 0 should output expected string")
112117

0 commit comments

Comments
 (0)