-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
shared_directory_arm64_test.go
88 lines (81 loc) · 2.25 KB
/
shared_directory_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
//go:build darwin && arm64
// +build darwin,arm64
package vz_test
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/Code-Hex/vz/v3"
)
func TestLinuxRosettaAvailabilityString(t *testing.T) {
cases := []struct {
availability vz.LinuxRosettaAvailability
want string
}{
{
availability: vz.LinuxRosettaAvailabilityNotSupported,
want: "LinuxRosettaAvailabilityNotSupported",
},
{
availability: vz.LinuxRosettaAvailabilityNotInstalled,
want: "LinuxRosettaAvailabilityNotInstalled",
},
{
availability: vz.LinuxRosettaAvailabilityInstalled,
want: "LinuxRosettaAvailabilityInstalled",
},
}
for _, tc := range cases {
got := tc.availability.String()
if tc.want != got {
t.Fatalf("want %q but got %q", tc.want, got)
}
}
}
func TestNewLinuxRosettaUnixSocketCachingOptions(t *testing.T) {
if vz.Available(14) {
t.Skip("NewLinuxRosettaUnixSocketCachingOptions is supported from macOS 14")
}
dir := t.TempDir()
t.Run("invalid filename length", func(t *testing.T) {
filename := filepath.Join(dir, strings.Repeat("a", 150)) + ".txt"
f, err := os.Create(filename)
if err != nil {
t.Fatal(err)
}
defer f.Close()
_, err = vz.NewLinuxRosettaUnixSocketCachingOptions(filename)
if err == nil {
t.Fatal("expected error")
}
if got := err.Error(); !strings.Contains(got, "maximum allowed length of") {
t.Fatalf("unexpected error: %q", got)
}
})
t.Run("invalid filename does not exists", func(t *testing.T) {
filename := "doesnotexists.txt"
_, err := vz.NewLinuxRosettaUnixSocketCachingOptions(filename)
if err == nil {
t.Fatal("expected error")
}
if got := err.Error(); !strings.Contains(got, "invalid path") {
t.Fatalf("unexpected error: %q", got)
}
})
}
func TestNewLinuxRosettaAbstractSocketCachingOptions(t *testing.T) {
if vz.Available(14) {
t.Skip("NewLinuxRosettaAbstractSocketCachingOptions is supported from macOS 14")
}
t.Run("invalid name length", func(t *testing.T) {
name := strings.Repeat("a", 350)
_, err := vz.NewLinuxRosettaAbstractSocketCachingOptions(name)
if err == nil {
t.Fatal("expected error")
}
if got := err.Error(); !strings.Contains(got, "maximum allowed length of") {
t.Fatalf("unexpected error: %q", got)
}
})
}