@@ -64,7 +64,7 @@ func TestIntegrationDockerCLI(t *testing.T) {
64
64
arch , err := dcli .DetectArchitecture (ctx , containerName )
65
65
require .NoError (t , err , "DetectArchitecture failed" )
66
66
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? " )
68
68
69
69
t .Logf ("Detected architecture: %s" , arch )
70
70
})
@@ -92,21 +92,26 @@ func TestIntegrationDockerCLI(t *testing.T) {
92
92
t .Parallel ()
93
93
94
94
// 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" )
97
97
require .NoError (t , err , "ExecAs without user should succeed" )
98
98
require .Equal (t , want , string (got ), "ExecAs without user should output expected string" )
99
- t .Logf ("ExecAs without user output: %s" , got )
100
99
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" )
104
109
require .NoError (t , err , "ExecAs with root user should succeed" )
105
110
require .Equal (t , want , string (got ), "ExecAs with root user should output expected string" )
106
111
107
112
// 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" )
110
115
require .NoError (t , err , "ExecAs with UID 0 should succeed" )
111
116
require .Equal (t , want , string (got ), "ExecAs with UID 0 should output expected string" )
112
117
0 commit comments