@@ -40,6 +40,37 @@ func TestValidateProbes(t *testing.T) {
40
40
assert .Error (t , err , "field `probe[0].file.digest` support is not yet implemented" )
41
41
}
42
42
43
+ func TestValidateProvisionMode (t * testing.T ) {
44
+ images := `images: [{location: /}]`
45
+ provisionBoot := `provision: [{mode: boot, script: "touch /tmp/param-$PARAM_BOOT"}]`
46
+ y , err := Load ([]byte (provisionBoot + "\n " + images ), "lima.yaml" )
47
+ assert .NilError (t , err )
48
+
49
+ err = Validate (y , false )
50
+ assert .NilError (t , err )
51
+
52
+ provisionUser := `provision: [{mode: user, script: "touch /tmp/param-$PARAM_USER"}]`
53
+ y , err = Load ([]byte (provisionUser + "\n " + images ), "lima.yaml" )
54
+ assert .NilError (t , err )
55
+
56
+ err = Validate (y , false )
57
+ assert .NilError (t , err )
58
+
59
+ provisionDependency := `provision: [{mode: ansible, script: "touch /tmp/param-$PARAM_DEPENDENCY"}]`
60
+ y , err = Load ([]byte (provisionDependency + "\n " + images ), "lima.yaml" )
61
+ assert .NilError (t , err )
62
+
63
+ err = Validate (y , false )
64
+ assert .NilError (t , err )
65
+
66
+ provisionInvalid := `provision: [{mode: invalid}]`
67
+ y , err = Load ([]byte (provisionInvalid + "\n " + images ), "lima.yaml" )
68
+ assert .NilError (t , err )
69
+
70
+ err = Validate (y , false )
71
+ assert .Error (t , err , "field `provision[0].mode` must one of \" system\" , \" user\" , \" boot\" , \" data\" , \" dependency\" , or \" ansible\" " )
72
+ }
73
+
43
74
func TestValidateProvisionData (t * testing.T ) {
44
75
images := `images: [{location: /}]`
45
76
validData := `provision: [{mode: data, path: /tmp, content: hello}]`
0 commit comments