forked from Code-Hex/vz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
osversion_arm64_test.go
97 lines (92 loc) · 2.4 KB
/
osversion_arm64_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//go:build darwin && arm64
// +build darwin,arm64
package vz
import (
"context"
"errors"
"sync"
"testing"
)
func TestAvailableVersionArm64(t *testing.T) {
majorMinorVersionOnce = &nopDoer{}
defer func() {
majorMinorVersion = 0
majorMinorVersionOnce = &sync.Once{}
}()
t.Run("macOS 12", func(t *testing.T) {
majorMinorVersion = 11
cases := map[string]func() error{
"NewMacOSBootLoader": func() error {
_, err := NewMacOSBootLoader()
return err
},
"NewMacGraphicsDeviceConfiguration": func() error {
_, err := NewMacGraphicsDeviceConfiguration()
return err
},
"NewMacGraphicsDisplayConfiguration": func() error {
_, err := NewMacGraphicsDisplayConfiguration(0, 0, 0)
return err
},
"NewMacPlatformConfiguration": func() error {
_, err := NewMacPlatformConfiguration()
return err
},
"NewMacHardwareModelWithData": func() error {
_, err := NewMacHardwareModelWithData(nil)
return err
},
"NewMacMachineIdentifierWithData": func() error {
_, err := NewMacMachineIdentifierWithData(nil)
return err
},
"NewMacMachineIdentifier": func() error {
_, err := NewMacMachineIdentifier()
return err
},
"NewMacAuxiliaryStorage": func() error {
_, err := NewMacAuxiliaryStorage("")
return err
},
"FetchLatestSupportedMacOSRestoreImage": func() error {
_, err := FetchLatestSupportedMacOSRestoreImage(context.Background(), "")
return err
},
"LoadMacOSRestoreImageFromPath": func() error {
_, err := LoadMacOSRestoreImageFromPath("")
return err
},
"NewMacOSInstaller": func() error {
_, err := NewMacOSInstaller(nil, "")
return err
},
}
for name, fn := range cases {
err := fn()
if !errors.Is(err, ErrUnsupportedOSVersion) {
t.Fatalf("unexpected error %v in %s", err, name)
}
}
})
t.Run("macOS 13", func(t *testing.T) {
if macOSBuildTargetAvailable(13) != nil {
t.Skip("disabled build target for macOS 13")
}
majorMinorVersion = 12.3
cases := map[string]func() error{
"WithStartUpFromMacOSRecovery": func() error {
return (*VirtualMachine)(nil).Start(WithStartUpFromMacOSRecovery(true))
},
"MacOSGuestAutomountTag": func() error {
_, err := MacOSGuestAutomountTag()
return err
},
}
for name, fn := range cases {
err := fn()
if !errors.Is(err, ErrUnsupportedOSVersion) {
t.Fatalf("unexpected error %v in %s", err, name)
}
}
})
}