Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/pkg/limayaml/validate_unix_test.go
2611 views
1
//go:build !windows
2
3
// SPDX-FileCopyrightText: Copyright The Lima Authors
4
// SPDX-License-Identifier: Apache-2.0
5
6
package limayaml
7
8
import (
9
"testing"
10
11
"gotest.tools/v3/assert"
12
)
13
14
func TestValidateMounts(t *testing.T) {
15
yBase := `images: [{"location": "/dummy"}]`
16
tests := []struct {
17
name string
18
mounts string
19
skipOnWindows bool
20
wantErr string
21
}{
22
{
23
name: "Valid",
24
mounts: `mounts: [{location: "/foo", writable: false}, {location: "~/foo", writable: true}]`,
25
wantErr: "",
26
},
27
{
28
name: "Invalid (relative)",
29
mounts: `mounts: [{location: ".", writable: false}]`,
30
wantErr: func() string {
31
return "must be an absolute path"
32
}(),
33
},
34
}
35
36
for _, tt := range tests {
37
t.Run(tt.name, func(t *testing.T) {
38
y, err := Load(t.Context(), []byte(yBase+"\n"+tt.mounts), "lima.yaml")
39
assert.NilError(t, err)
40
err = Validate(y, false)
41
if tt.wantErr != "" {
42
assert.ErrorContains(t, err, tt.wantErr)
43
} else {
44
assert.NilError(t, err)
45
}
46
})
47
}
48
}
49
50