@@ -30,9 +30,15 @@ func TestArgExprEnv_JSONSerialization(t *testing.T) {
3030 t .Parallel ()
3131
3232 env := zapscript.ArgExprEnv {
33- Platform : "mister" ,
34- Version : "2.0.0" ,
35- ScanMode : "hold" ,
33+ Platform : "mister" ,
34+ Version : "2.0.0" ,
35+ ScanMode : "hold" ,
36+ MediaPlaying : true ,
37+ MediaReady : true ,
38+ Hook : zapscript.ExprEnvHook {
39+ Name : "startup" ,
40+ FirstBootStart : true ,
41+ },
3642 Device : zapscript.ExprEnvDevice {
3743 Hostname : "mister" ,
3844 OS : "linux" ,
@@ -43,7 +49,6 @@ func TestArgExprEnv_JSONSerialization(t *testing.T) {
4349 Value : "**launch:snes/mario" ,
4450 Data : "extra-data" ,
4551 },
46- MediaPlaying : true ,
4752 ActiveMedia : zapscript.ExprEnvActiveMedia {
4853 LauncherID : "retroarch" ,
4954 SystemID : "snes" ,
@@ -63,6 +68,9 @@ func TestArgExprEnv_JSONSerialization(t *testing.T) {
6368 assert .Contains (t , jsonStr , `"version"` , "should contain version field" )
6469 assert .Contains (t , jsonStr , `"scan_mode"` , "should contain scan_mode field" )
6570 assert .Contains (t , jsonStr , `"media_playing"` , "should contain media_playing field" )
71+ assert .Contains (t , jsonStr , `"media_ready"` , "should contain media_ready field" )
72+ assert .Contains (t , jsonStr , `"hook"` , "should contain hook field" )
73+ assert .Contains (t , jsonStr , `"first_boot_start"` , "should contain first_boot_start field" )
6674 assert .Contains (t , jsonStr , `"active_media"` , "should contain active_media field" )
6775 assert .Contains (t , jsonStr , `"last_scanned"` , "should contain last_scanned field" )
6876 assert .Contains (t , jsonStr , `"launcher_id"` , "should contain launcher_id field" )
@@ -85,6 +93,11 @@ func TestArgExprEnv_JSONRoundTrip(t *testing.T) {
8593 Version : "1.0.0" ,
8694 ScanMode : "tap" ,
8795 MediaPlaying : true ,
96+ MediaReady : true ,
97+ Hook : zapscript.ExprEnvHook {
98+ Name : "startup" ,
99+ FirstBootStart : true ,
100+ },
88101 Device : zapscript.ExprEnvDevice {
89102 Hostname : "testhost" ,
90103 OS : "linux" ,
@@ -115,6 +128,9 @@ func TestArgExprEnv_JSONRoundTrip(t *testing.T) {
115128 assert .Equal (t , original .Version , decoded .Version )
116129 assert .Equal (t , original .ScanMode , decoded .ScanMode )
117130 assert .Equal (t , original .MediaPlaying , decoded .MediaPlaying )
131+ assert .Equal (t , original .MediaReady , decoded .MediaReady )
132+ assert .Equal (t , original .Hook .Name , decoded .Hook .Name )
133+ assert .Equal (t , original .Hook .FirstBootStart , decoded .Hook .FirstBootStart )
118134 assert .Equal (t , original .Device .Hostname , decoded .Device .Hostname )
119135 assert .Equal (t , original .LastScanned .ID , decoded .LastScanned .ID )
120136 assert .Equal (t , original .ActiveMedia .Path , decoded .ActiveMedia .Path )
@@ -158,6 +174,22 @@ func TestExprEnvLaunching_JSONSerialization(t *testing.T) {
158174 assert .Contains (t , jsonStr , `"launcher_id"` )
159175}
160176
177+ func TestExprEnvHook_JSONSerialization (t * testing.T ) {
178+ t .Parallel ()
179+
180+ hook := zapscript.ExprEnvHook {
181+ Name : "startup" ,
182+ FirstBootStart : true ,
183+ }
184+
185+ jsonBytes , err := json .Marshal (hook )
186+ require .NoError (t , err )
187+
188+ jsonStr := string (jsonBytes )
189+ assert .Contains (t , jsonStr , `"name"` )
190+ assert .Contains (t , jsonStr , `"first_boot_start"` )
191+ }
192+
161193// TestArgExprEnv_EmptyFieldsSerialization verifies that empty struct fields are serialized
162194// (no omitempty behavior) for consistent JSON structure in external scripts.
163195func TestArgExprEnv_EmptyFieldsSerialization (t * testing.T ) {
0 commit comments