@@ -19,61 +19,59 @@ func TestStableToUnstable(t *testing.T) {
1919 FetchDebPackage (t , "build/stable" , "arduino-router" , "latest" , * arch )
2020 majorTag := majorTag (t , tagAppCli )
2121 _ = minorTag (t , tagAppCli )
22+
2223 fmt .Printf ("Updating from stable version %s to unstable version %s \n " , tagAppCli , majorTag )
2324 fmt .Printf ("Building local deb version %s \n " , majorTag )
2425 buildDebVersion (t , "build" , majorTag , * arch )
25- fmt .Printf ("Check folder structure and deb downloaded\n " )
26- ls (t )
27- fmt .Println ("**** BUILD docker image *****" )
28- buildDockerImage (t , "test.Dockerfile" , "apt-test-update-image" , * arch )
29- fmt .Println ("**** RUN docker image *****" )
30- runDockerContainer (t , "apt-test-update" , "apt-test-update-image" )
31- preUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
32- runDockerSystemUpdate (t , "apt-test-update" )
33- postUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
34- runDockerCleanUp (t , "apt-test-update" )
35- require .Equal (t , preUpdateVersion , "Arduino App CLI " + tagAppCli + "\n " )
36- require .Equal (t , postUpdateVersion , "Arduino App CLI " + majorTag + "\n " )
37- }
3826
39- func TestClientUpdateStU (t * testing.T ) {
27+ t . Run ( "CLI Update Testing" , func (t * testing.T ) {
4028
41- fmt .Printf ("***** ARCH %s ***** \n " , * arch )
42- tagAppCli := FetchDebPackage (t , "build/stable" , "arduino-app-cli" , "latest" , * arch )
43- FetchDebPackage (t , "build/stable" , "arduino-router" , "latest" , * arch )
44- majorTag := majorTag (t , tagAppCli )
29+ fmt .Printf ("Check folder structure and deb downloaded\n " )
30+ ls (t )
31+ fmt .Println ("**** BUILD docker image *****" )
32+ buildDockerImage (t , "test.Dockerfile" , "apt-test-update-image" , * arch )
33+ fmt .Println ("**** RUN docker image *****" )
34+ runDockerContainer (t , "apt-test-update" , "apt-test-update-image" )
35+ preUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
36+ runDockerSystemUpdate (t , "apt-test-update" )
37+ postUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
38+ runDockerCleanUp (t , "apt-test-update" )
39+ require .Equal (t , preUpdateVersion , "Arduino App CLI " + tagAppCli + "\n " )
40+ require .Equal (t , postUpdateVersion , "Arduino App CLI " + majorTag + "\n " )
41+ })
4542
46- fmt . Println ( "**** RUN docker image *****" )
47- runDockerContainer (t , "apt-test-update" , "apt-test-update-image" )
48- preUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
43+ t . Run ( "Client Daemon Request Testing" , func ( t * testing. T ) {
44+ runDockerContainer (t , "apt-test-update" , "apt-test-update-image" )
45+ preUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
4946
50- status := runDockerDaemon (t , "apt-test-update" )
51- WaitForPort (t , "127.0.0.1" , "8800" , 5 * time .Second )
47+ status := runDockerDaemon (t , "apt-test-update" )
48+ WaitForPort (t , "127.0.0.1" , "8800" , 5 * time .Second )
5249
53- status = putUpdateRequest (t , "http://127.0.0.1:8800/v1/system/update/apply" )
54- if status != "202 Accepted" {
55- log .Fatalf ("Error putting update request: %s" , status )
56- }
50+ status = putUpdateRequest (t , "http://127.0.0.1:8800/v1/system/update/apply" )
51+ if status != "202 Accepted" {
52+ log .Fatalf ("Error putting update request: %s" , status )
53+ }
5754
58- itr := NewSSEClient (context .Background (), "GET" , "http://localhost:8800/v1/system/update/events" )
55+ itr := NewSSEClient (context .Background (), "GET" , "http://localhost:8800/v1/system/update/events" )
5956
60- for event , err := range itr {
61- if err != nil {
62- log .Printf ("Error receiving SSE event: %v" , err )
63- }
64- fmt .Printf ("Received event: ID=%s, Event=%s, Data=%s\n " , event .ID , event .Event , string (event .Data ))
65- if string (event .Data ) == "Download complete" {
66- fmt .Println ("✅ Download complete — exiting successfully." )
67- break
57+ for event , err := range itr {
58+ if err != nil {
59+ log .Printf ("Error receiving SSE event: %v" , err )
60+ }
61+ fmt .Printf ("Received event: ID=%s, Event=%s, Data=%s\n " , event .ID , event .Event , string (event .Data ))
62+ if string (event .Data ) == "Download complete" {
63+ fmt .Println ("✅ Download complete — exiting successfully." )
64+ break
65+ }
6866 }
69- }
70-
71- postUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
7267
73- require .Equal (t , preUpdateVersion , "Arduino App CLI " + tagAppCli + "\n " )
74- require .Equal (t , postUpdateVersion , "Arduino App CLI " + majorTag + "\n " )
75- runDockerCleanUp (t , "apt-test-update" )
68+ postUpdateVersion := runDockerSystemVersion (t , "apt-test-update" )
7669
70+ require .Equal (t , preUpdateVersion , "Arduino App CLI " + tagAppCli + "\n " )
71+ require .Equal (t , postUpdateVersion , "Arduino App CLI " + majorTag + "\n " )
72+ runDockerCleanUp (t , "apt-test-update" )
73+ })
74+ rmrf (t , "build" )
7775}
7876
7977func TestUnstableToStable (t * testing.T ) {
0 commit comments