@@ -30,6 +30,7 @@ func TestConfig(t *testing.T) {
3030 assert .NilError (t , err )
3131 t .Log (string (config ))
3232 assert .Assert (t , ! strings .Contains (string (config ), "ca_certs:" ))
33+ assert .Assert (t , ! strings .Contains (string (config ), "mounts:" ))
3334}
3435
3536func TestConfigCACerts (t * testing.T ) {
@@ -54,6 +55,51 @@ func TestConfigCACerts(t *testing.T) {
5455 assert .Assert (t , strings .Contains (string (config ), "ca_certs:" ))
5556}
5657
58+ var defaultMounts = []Mount {
59+ {MountPoint : "/home/foo.linux" , Tag : "mount0" , Type : "virtiofs" , Options : "ro" },
60+ {MountPoint : "/tmp/lima" , Tag : "mount1" , Type : "virtiofs" },
61+ }
62+
63+ func TestConfigMounts (t * testing.T ) {
64+ args := & TemplateArgs {
65+ Name : "default" ,
66+ User : "foo" ,
67+ UID : 501 ,
68+ Comment : "Foo" ,
69+ Home : "/home/foo.linux" ,
70+ Shell : "/bin/bash" ,
71+ SSHPubKeys : []string {
72+ "ssh-rsa dummy foo@example.com" ,
73+ },
74+ MountType : "virtiofs" , // override
75+ Mounts : defaultMounts ,
76+ }
77+ config , err := ExecuteTemplateCloudConfig (args )
78+ assert .NilError (t , err )
79+ t .Log (string (config ))
80+ assert .Assert (t , strings .Contains (string (config ), "mounts:" ))
81+ }
82+
83+ func TestConfigMountsNone (t * testing.T ) {
84+ args := & TemplateArgs {
85+ Name : "default" ,
86+ User : "foo" ,
87+ UID : 501 ,
88+ Comment : "Foo" ,
89+ Home : "/home/foo.linux" ,
90+ Shell : "/bin/bash" ,
91+ SSHPubKeys : []string {
92+ "ssh-rsa dummy foo@example.com" ,
93+ },
94+ MountType : "virtiofs" , // override
95+ Mounts : []Mount {},
96+ }
97+ config , err := ExecuteTemplateCloudConfig (args )
98+ assert .NilError (t , err )
99+ t .Log (string (config ))
100+ assert .Assert (t , ! strings .Contains (string (config ), "mounts:" ))
101+ }
102+
57103func TestTemplate (t * testing.T ) {
58104 args := & TemplateArgs {
59105 Name : "default" ,
0 commit comments