@@ -33,7 +33,7 @@ func TestStableToUnstable(t *testing.T) {
3333 fmt .Println ("**** BUILD docker image *****" )
3434 buildDockerImage (t , "test.Dockerfile" , "apt-test-update-image" , * arch )
3535 fmt .Println ("**** RUN docker image *****" )
36- runDockerCommand ( t , "apt-test-update-image" )
36+ runDockerContainer ( t , "apt-test-update" , "apt-test-update-image" )
3737 preUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
3838 runDockerSystemUpdate (t , "apt-test-update" )
3939 postUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
@@ -52,16 +52,19 @@ func TestUnstableToStable(t *testing.T) {
5252 fmt .Printf ("Updating from unstable version %s to stable version %s \n " , minorTag , tagAppCli )
5353 fmt .Printf ("Building local deb version %s \n " , minorTag )
5454 buildDebVersion (t , minorTag , * arch )
55- moveDeb (t , "build/" , "build/stable" , "arduino-app-cli" , tagAppCli , * arch )
55+ moveDeb (t , "build/" , "build/stable" , "arduino-app-cli" , minorTag , * arch )
56+
57+ fmt .Printf ("Check folder structure and deb downloaded\n " )
58+ ls (t )
5659
5760 fmt .Println ("**** BUILD docker image *****" )
58- buildDockerImage (t , "test.Dockerfile" , "test-apt-update-unstable" , * arch )
61+ buildDockerImage (t , "test.Dockerfile" , "test-apt-update-unstable-image " , * arch )
5962 fmt .Println ("**** RUN docker image *****" )
60- runDockerCommand (t , "test-apt-update-unstable" )
61- preUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
62- runDockerSystemUpdate (t , "apt-test-update" )
63- postUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
64- runDockerCleanUp (t , "apt-test-update" )
63+ runDockerContainer (t , "test-apt-update-unstable-image" , "apt-test -update-unstable" )
64+ preUpdateVersion := runDockerSystemVersion (t , "apt-test-update-unstable " )
65+ runDockerSystemUpdate (t , "apt-test-update-unstable " )
66+ postUpdateVersion := runDockerSystemVersion (t , "apt-test-update-unstable " )
67+ runDockerCleanUp (t , "apt-test-update-unstable " )
6568 require .Equal (t , preUpdateVersion , "Arduino App CLI " + tagAppCli + "\n " )
6669 require .Equal (t , postUpdateVersion , "Arduino App CLI " + minorTag + "\n " )
6770
@@ -194,7 +197,7 @@ func buildDockerImage(t *testing.T, dockerfile, name, arch string) {
194197
195198}
196199
197- func runDockerCommand (t * testing.T , containerImageName string ) {
200+ func runDockerContainer (t * testing.T , containerName string , containerImageName string ) {
198201 t .Helper ()
199202
200203 cmd := exec .Command (
@@ -204,7 +207,7 @@ func runDockerCommand(t *testing.T, containerImageName string) {
204207 "-v" , "/sys/fs/cgroup:/sys/fs/cgroup:rw" ,
205208 "-v" , "/var/run/docker.sock:/var/run/docker.sock" ,
206209 "-e" , "DOCKER_HOST=unix:///var/run/docker.sock" ,
207- "--name" , "apt-test-update" ,
210+ "--name" , containerName ,
208211 containerImageName ,
209212 )
210213
@@ -253,6 +256,25 @@ func runDockerSystemUpdate(t *testing.T, containerName string) {
253256
254257}
255258
259+ func runDockerDaemon (t * testing.T , containerName string ) string {
260+ t .Helper ()
261+
262+ cmd := exec .Command (
263+ "docker" , "exec" ,
264+ "--user" , "arduino" ,
265+ containerName ,
266+ "arduino-app-cli" , "daemon" ,
267+ )
268+
269+ output , err := cmd .CombinedOutput ()
270+ if err != nil {
271+ log .Fatalf ("command failed: %v\n Output: %s" , err , output )
272+ }
273+
274+ return string (output )
275+
276+ }
277+
256278func runDockerCleanUp (t * testing.T , containerName string ) {
257279 t .Helper ()
258280
@@ -277,6 +299,8 @@ func moveDeb(t *testing.T, startDir, targetDir, repo string, tagVersion string,
277299 if err := moveCmd .Run (); err != nil {
278300 panic (fmt .Errorf ("failed to move deb file: %w" , err ))
279301 }
302+
303+ rm (t , debFile )
280304}
281305
282306func ls (t * testing.T ) {
@@ -300,3 +324,16 @@ func ls(t *testing.T) {
300324 })
301325
302326}
327+
328+ func rm (t * testing.T , pathFile string ) {
329+ t .Helper ()
330+ removeCmd := exec .Command ("rm" , pathFile )
331+
332+ err := removeCmd .Run ()
333+ if err != nil {
334+ log .Fatalf ("Failed to remove file: %v" , err )
335+ }
336+
337+ fmt .Printf ("📦 Removed %s\n " , pathFile )
338+
339+ }
0 commit comments