@@ -295,6 +295,75 @@ func TestNewPlatformMap(t *testing.T) {
295295 assert .Equal (t , "mac" , * pm .MacOS )
296296 assert .Nil (t , pm .Linux )
297297 })
298+
299+ t .Run ("handles map[any]any from YAML unmarshaling" , func (t * testing.T ) {
300+ // Simulate what YAML unmarshaling produces for nested maps
301+ input := map [any ]any {
302+ "macos" : "mac-value" ,
303+ "linux" : "linux-value" ,
304+ "windows" : "windows-value" ,
305+ }
306+ pm := NewPlatformMap [string ](input )
307+ assert .Equal (t , "mac-value" , * pm .MacOS )
308+ assert .Equal (t , "linux-value" , * pm .Linux )
309+ assert .Equal (t , "windows-value" , * pm .Windows )
310+ })
311+
312+ t .Run ("handles map[any]any with partial platforms" , func (t * testing.T ) {
313+ input := map [any ]any {
314+ "macos" : "mac-only" ,
315+ }
316+ pm := NewPlatformMap [string ](input )
317+ assert .Equal (t , "mac-only" , * pm .MacOS )
318+ assert .Nil (t , pm .Linux )
319+ assert .Nil (t , pm .Windows )
320+ })
321+
322+ t .Run ("handles map[string]any from JSON unmarshaling" , func (t * testing.T ) {
323+ // Simulate what JSON unmarshaling or mixed YAML produces
324+ input := map [string ]any {
325+ "macos" : "mac-value" ,
326+ "linux" : "linux-value" ,
327+ "windows" : "windows-value" ,
328+ }
329+ pm := NewPlatformMap [string ](input )
330+ assert .Equal (t , "mac-value" , * pm .MacOS )
331+ assert .Equal (t , "linux-value" , * pm .Linux )
332+ assert .Equal (t , "windows-value" , * pm .Windows )
333+ })
334+
335+ t .Run ("handles map[string]any with partial platforms" , func (t * testing.T ) {
336+ input := map [string ]any {
337+ "linux" : "linux-only" ,
338+ }
339+ pm := NewPlatformMap [string ](input )
340+ assert .Nil (t , pm .MacOS )
341+ assert .Equal (t , "linux-only" , * pm .Linux )
342+ assert .Nil (t , pm .Windows )
343+ })
344+
345+ t .Run ("handles map[any]any with non-string keys gracefully" , func (t * testing.T ) {
346+ // Non-string keys should be ignored
347+ input := map [any ]any {
348+ "macos" : "mac-value" ,
349+ 123 : "ignored" ,
350+ }
351+ pm := NewPlatformMap [string ](input )
352+ assert .Equal (t , "mac-value" , * pm .MacOS )
353+ assert .Nil (t , pm .Linux )
354+ assert .Nil (t , pm .Windows )
355+ })
356+
357+ t .Run ("handles map[any]any with wrong value type gracefully" , func (t * testing.T ) {
358+ // Wrong value types should be ignored
359+ input := map [any ]any {
360+ "macos" : "mac-value" ,
361+ "linux" : 123 , // wrong type, should be ignored
362+ }
363+ pm := NewPlatformMap [string ](input )
364+ assert .Equal (t , "mac-value" , * pm .MacOS )
365+ assert .Nil (t , pm .Linux )
366+ })
298367}
299368
300369func TestSetOSAndSetArch (t * testing.T ) {
0 commit comments