@@ -31,7 +31,6 @@ func TestFillDefault(t *testing.T) {
31
31
logrus .SetLevel (logrus .DebugLevel )
32
32
var d , y , o limatype.LimaYAML
33
33
34
- defaultVMType := limatype .QEMU
35
34
opts := []cmp.Option {
36
35
// Consider nil slices and empty slices to be identical
37
36
cmpopts .EquateEmpty (),
@@ -76,7 +75,6 @@ func TestFillDefault(t *testing.T) {
76
75
77
76
// Builtin default values
78
77
builtin := limatype.LimaYAML {
79
- VMType : & defaultVMType ,
80
78
OS : ptr .Of (limatype .LINUX ),
81
79
Arch : ptr .Of (arch ),
82
80
CPUs : ptr .Of (defaultCPUs ()),
@@ -105,9 +103,6 @@ func TestFillDefault(t *testing.T) {
105
103
},
106
104
Video : limatype.Video {
107
105
Display : ptr .Of ("none" ),
108
- VNC : limatype.VNCOptions {
109
- Display : ptr .Of ("127.0.0.1:0,to=9" ),
110
- },
111
106
},
112
107
HostResolver : limatype.HostResolver {
113
108
Enabled : ptr .Of (true ),
@@ -194,31 +189,11 @@ func TestFillDefault(t *testing.T) {
194
189
},
195
190
},
196
191
TimeZone : ptr .Of ("Antarctica/Troll" ),
197
- Firmware : limatype.Firmware {
198
- LegacyBIOS : ptr .Of (false ),
199
- Images : []limatype.FileWithVMType {
200
- {
201
- File : limatype.File {
202
- Location : "https://gitlab.com/kraxel/qemu/-/raw/704f7cad5105246822686f65765ab92045f71a3b/pc-bios/edk2-aarch64-code.fd.bz2" ,
203
- Arch : limatype .AARCH64 ,
204
- Digest : "sha256:a5fc228623891297f2d82e22ea56ec57cde93fea5ec01abf543e4ed5cacaf277" ,
205
- },
206
- VMType : limatype .QEMU ,
207
- },
208
- {
209
- File : limatype.File {
210
- Location : "https://github.com/AkihiroSuda/qemu/raw/704f7cad5105246822686f65765ab92045f71a3b/pc-bios/edk2-aarch64-code.fd.bz2" ,
211
- Arch : limatype .AARCH64 ,
212
- Digest : "sha256:a5fc228623891297f2d82e22ea56ec57cde93fea5ec01abf543e4ed5cacaf277" ,
213
- },
214
- VMType : limatype .QEMU ,
215
- },
216
- },
217
- },
218
192
}
219
193
220
194
expect := builtin
221
- expect .VMType = ptr .Of (limatype .QEMU ) // due to NINEP
195
+ // VMType should remain nil when not explicitly set (will be resolved by ValidateVMType later)
196
+ expect .VMType = nil
222
197
expect .HostResolver .Hosts = map [string ]string {
223
198
"MY.Host" : "host.lima.internal" ,
224
199
}
@@ -312,8 +287,12 @@ func TestFillDefault(t *testing.T) {
312
287
}
313
288
314
289
expect .TimeZone = y .TimeZone
315
- expect .Firmware = y .Firmware
316
- expect .Firmware .Images = slices .Clone (y .Firmware .Images )
290
+ // Set firmware expectations to match what FillDefault actually does
291
+ // FillDefault uses the builtin default values, which include LegacyBIOS: ptr.Of(false)
292
+ expect .Firmware = limatype.Firmware {
293
+ LegacyBIOS : ptr .Of (false ), // This matches what FillDefault actually sets
294
+ Images : nil ,
295
+ }
317
296
318
297
expect .Rosetta = limatype.Rosetta {
319
298
Enabled : ptr .Of (false ),
@@ -335,7 +314,7 @@ func TestFillDefault(t *testing.T) {
335
314
// Calling filepath.Abs() to add a drive letter on Windows
336
315
varLog , _ := filepath .Abs ("/var/log" )
337
316
d = limatype.LimaYAML {
338
- VMType : ptr . Of ( "vz" ),
317
+ // Remove driver-specific VMType from defaults test
339
318
OS : ptr .Of ("unknown" ),
340
319
Arch : ptr .Of ("unknown" ),
341
320
CPUs : ptr .Of (7 ),
@@ -363,23 +342,14 @@ func TestFillDefault(t *testing.T) {
363
342
TimeZone : ptr .Of ("Zulu" ),
364
343
Firmware : limatype.Firmware {
365
344
LegacyBIOS : ptr .Of (true ),
366
- Images : []limatype.FileWithVMType {
367
- {
368
- File : limatype.File {
369
- Location : "/dummy" ,
370
- Arch : limatype .X8664 ,
371
- },
372
- },
373
- },
345
+ // Remove driver-specific firmware images from defaults
374
346
},
375
347
Audio : limatype.Audio {
376
348
Device : ptr .Of ("coreaudio" ),
377
349
},
378
350
Video : limatype.Video {
379
351
Display : ptr .Of ("cocoa" ),
380
- VNC : limatype.VNCOptions {
381
- Display : ptr .Of ("none" ),
382
- },
352
+ // Remove driver-specific VNC configuration
383
353
},
384
354
HostResolver : limatype.HostResolver {
385
355
Enabled : ptr .Of (false ),
@@ -458,6 +428,8 @@ func TestFillDefault(t *testing.T) {
458
428
}
459
429
460
430
expect = d
431
+ // VMType should remain nil when not explicitly set
432
+ expect .VMType = nil
461
433
// Also verify that archive arch is filled in
462
434
expect .Containerd .Archives = slices .Clone (d .Containerd .Archives )
463
435
expect .Containerd .Archives [0 ].Arch = * d .Arch
@@ -480,7 +452,8 @@ func TestFillDefault(t *testing.T) {
480
452
expect .HostResolver .Hosts = map [string ]string {
481
453
"default" : d .HostResolver .Hosts ["default" ],
482
454
}
483
- expect .MountType = ptr .Of (limatype .VIRTIOFS )
455
+ // Remove driver-specific mount type from defaults test
456
+ expect .MountType = nil
484
457
expect .MountInotify = ptr .Of (false )
485
458
expect .CACertificates .RemoveDefaults = ptr .Of (true )
486
459
expect .CACertificates .Certs = []string {
@@ -504,7 +477,7 @@ func TestFillDefault(t *testing.T) {
504
477
FillDefault (& y , & d , & limatype.LimaYAML {}, filePath , false )
505
478
assert .DeepEqual (t , & y , & expect , opts ... )
506
479
507
- dExpect := expect
480
+ dExpected := expect
508
481
509
482
// ------------------------------------------------------------------------------------
510
483
// User-provided defaults should not override user-provided config values
@@ -516,29 +489,29 @@ func TestFillDefault(t *testing.T) {
516
489
517
490
expect = y
518
491
519
- expect .Provision = slices .Concat (y .Provision , dExpect .Provision )
520
- expect .Probes = slices .Concat (y .Probes , dExpect .Probes )
521
- expect .PortForwards = slices .Concat (y .PortForwards , dExpect .PortForwards )
522
- expect .CopyToHost = slices .Concat (y .CopyToHost , dExpect .CopyToHost )
523
- expect .Containerd .Archives = slices .Concat (y .Containerd .Archives , dExpect .Containerd .Archives )
492
+ expect .Provision = slices .Concat (y .Provision , dExpected .Provision )
493
+ expect .Probes = slices .Concat (y .Probes , dExpected .Probes )
494
+ expect .PortForwards = slices .Concat (y .PortForwards , dExpected .PortForwards )
495
+ expect .CopyToHost = slices .Concat (y .CopyToHost , dExpected .CopyToHost )
496
+ expect .Containerd .Archives = slices .Concat (y .Containerd .Archives , dExpected .Containerd .Archives )
524
497
expect .Containerd .Archives [2 ].Arch = * expect .Arch
525
- expect .AdditionalDisks = slices .Concat (y .AdditionalDisks , dExpect .AdditionalDisks )
526
- expect .Firmware .Images = slices .Concat (y .Firmware .Images , dExpect .Firmware .Images )
498
+ expect .AdditionalDisks = slices .Concat (y .AdditionalDisks , dExpected .AdditionalDisks )
499
+ expect .Firmware .Images = slices .Concat (y .Firmware .Images , dExpected .Firmware .Images )
527
500
528
501
// Mounts and Networks start with lowest priority first, so higher priority entries can overwrite
529
- expect .Mounts = slices .Concat (dExpect .Mounts , y .Mounts )
530
- expect .Networks = slices .Concat (dExpect .Networks , y .Networks )
502
+ expect .Mounts = slices .Concat (dExpected .Mounts , y .Mounts )
503
+ expect .Networks = slices .Concat (dExpected .Networks , y .Networks )
531
504
532
- expect .HostResolver .Hosts ["default" ] = dExpect .HostResolver .Hosts ["default" ]
505
+ expect .HostResolver .Hosts ["default" ] = dExpected .HostResolver .Hosts ["default" ]
533
506
534
- // dExpect .DNS will be ignored, and not appended to y.DNS
507
+ // dExpected .DNS will be ignored, and not appended to y.DNS
535
508
536
- // "TWO" does not exist in filledDefaults.Env, so is set from dExpect .Env
537
- expect .Env ["TWO" ] = dExpect .Env ["TWO" ]
509
+ // "TWO" does not exist in filledDefaults.Env, so is set from dExpected .Env
510
+ expect .Env ["TWO" ] = dExpected .Env ["TWO" ]
538
511
539
- expect .Param ["TWO" ] = dExpect .Param ["TWO" ]
512
+ expect .Param ["TWO" ] = dExpected .Param ["TWO" ]
540
513
541
- t .Logf ("d.vmType=%q , y.vmType=%q , expect.vmType=%q " , * d .VMType , * y .VMType , * expect .VMType )
514
+ t .Logf ("d.vmType=%v , y.vmType=%v , expect.vmType=%v " , d .VMType , y .VMType , expect .VMType )
542
515
543
516
FillDefault (& y , & d , & limatype.LimaYAML {}, filePath , false )
544
517
assert .DeepEqual (t , & y , & expect , opts ... )
@@ -547,7 +520,7 @@ func TestFillDefault(t *testing.T) {
547
520
// User-provided overrides should override user-provided config settings
548
521
549
522
o = limatype.LimaYAML {
550
- VMType : ptr . Of ( "qemu" ),
523
+ // Remove driver-specific VMType from override test
551
524
OS : ptr .Of (limatype .LINUX ),
552
525
Arch : ptr .Of (arch ),
553
526
CPUs : ptr .Of (12 ),
@@ -585,9 +558,7 @@ func TestFillDefault(t *testing.T) {
585
558
},
586
559
Video : limatype.Video {
587
560
Display : ptr .Of ("cocoa" ),
588
- VNC : limatype.VNCOptions {
589
- Display : ptr .Of ("none" ),
590
- },
561
+ // Remove driver-specific VNC configuration
591
562
},
592
563
HostResolver : limatype.HostResolver {
593
564
Enabled : ptr .Of (false ),
@@ -685,20 +656,20 @@ func TestFillDefault(t *testing.T) {
685
656
686
657
expect = o
687
658
688
- expect .Provision = slices .Concat (o .Provision , y .Provision , dExpect .Provision )
689
- expect .Probes = slices .Concat (o .Probes , y .Probes , dExpect .Probes )
690
- expect .PortForwards = slices .Concat (o .PortForwards , y .PortForwards , dExpect .PortForwards )
691
- expect .CopyToHost = slices .Concat (o .CopyToHost , y .CopyToHost , dExpect .CopyToHost )
692
- expect .Containerd .Archives = slices .Concat (o .Containerd .Archives , y .Containerd .Archives , dExpect .Containerd .Archives )
659
+ expect .Provision = slices .Concat (o .Provision , y .Provision , dExpected .Provision )
660
+ expect .Probes = slices .Concat (o .Probes , y .Probes , dExpected .Probes )
661
+ expect .PortForwards = slices .Concat (o .PortForwards , y .PortForwards , dExpected .PortForwards )
662
+ expect .CopyToHost = slices .Concat (o .CopyToHost , y .CopyToHost , dExpected .CopyToHost )
663
+ expect .Containerd .Archives = slices .Concat (o .Containerd .Archives , y .Containerd .Archives , dExpected .Containerd .Archives )
693
664
expect .Containerd .Archives [3 ].Arch = * expect .Arch
694
- expect .AdditionalDisks = slices .Concat (o .AdditionalDisks , y .AdditionalDisks , dExpect .AdditionalDisks )
695
- expect .Firmware .Images = slices .Concat (o .Firmware .Images , y .Firmware .Images , dExpect .Firmware .Images )
665
+ expect .AdditionalDisks = slices .Concat (o .AdditionalDisks , y .AdditionalDisks , dExpected .AdditionalDisks )
666
+ expect .Firmware .Images = slices .Concat (o .Firmware .Images , y .Firmware .Images , dExpected .Firmware .Images )
696
667
697
- expect .HostResolver .Hosts ["default" ] = dExpect .HostResolver .Hosts ["default" ]
698
- expect .HostResolver .Hosts ["MY.Host" ] = dExpect .HostResolver .Hosts ["host.lima.internal" ]
668
+ expect .HostResolver .Hosts ["default" ] = dExpected .HostResolver .Hosts ["default" ]
669
+ expect .HostResolver .Hosts ["MY.Host" ] = dExpected .HostResolver .Hosts ["host.lima.internal" ]
699
670
700
- // o.Mounts just makes dExpect .Mounts[0] writable because the Location matches
701
- expect .Mounts = slices .Concat (dExpect .Mounts , y .Mounts )
671
+ // o.Mounts just makes dExpected .Mounts[0] writable because the Location matches
672
+ expect .Mounts = slices .Concat (dExpected .Mounts , y .Mounts )
702
673
expect .Mounts [0 ].Writable = ptr .Of (true )
703
674
expect .Mounts [0 ].SSHFS .Cache = ptr .Of (false )
704
675
expect .Mounts [0 ].SSHFS .FollowSymlinks = ptr .Of (true )
@@ -711,8 +682,8 @@ func TestFillDefault(t *testing.T) {
711
682
expect .MountType = ptr .Of (limatype .NINEP )
712
683
expect .MountInotify = ptr .Of (true )
713
684
714
- // o.Networks[1] is overriding the dExpect .Networks[0].Lima entry for the "def0" interface
715
- expect .Networks = slices .Concat (dExpect .Networks , y .Networks , []limatype.Network {o .Networks [0 ]})
685
+ // o.Networks[1] is overriding the dExpected .Networks[0].Lima entry for the "def0" interface
686
+ expect .Networks = slices .Concat (dExpected .Networks , y .Networks , []limatype.Network {o .Networks [0 ]})
716
687
expect .Networks [0 ].Lima = o .Networks [1 ].Lima
717
688
718
689
// Only highest prio DNS are retained
0 commit comments