@@ -279,3 +279,71 @@ func TestValidateDevEnvConfig_PythonBinPathMustBeAbsolute(t *testing.T) {
279279 assert .Contains (t , err .Error (), "pythonBinPath" )
280280 assert .Contains (t , err .Error (), "absolute path" )
281281}
282+
283+ func TestValidator_MountPath (t * testing.T ) {
284+ type S struct {
285+ Path string `validate:"mount_path"`
286+ }
287+
288+ cases := []struct {
289+ name string
290+ val string
291+ ok bool
292+ }{
293+ {name : "root mount dir" , val : "/mnt" , ok : true },
294+ {name : "mount subpath" , val : "/mnt/data" , ok : true },
295+ {name : "root" , val : "/" , ok : true },
296+ {name : "empty" , val : "" , ok : false },
297+ {name : "whitespace" , val : " " , ok : false },
298+ {name : "relative path" , val : "mnt/data" , ok : false },
299+ }
300+
301+ for _ , tc := range cases {
302+ t .Run (tc .name , func (t * testing.T ) {
303+ err := validate .Struct (& S {Path : tc .val })
304+ if tc .ok {
305+ require .NoError (t , err )
306+ } else {
307+ require .Error (t , err )
308+ }
309+ })
310+ }
311+ }
312+
313+ func TestValidateDevEnvConfig_VolumeMountPaths (t * testing.T ) {
314+ newCfg := func (localPath , containerPath string ) * DevEnvConfig {
315+ return & DevEnvConfig {
316+ Name : "alice" ,
317+ BaseConfig : BaseConfig {
318+ SSHPublicKey : "ssh-ed25519 AAAAB3NzaC1lZDI1NTE5AAAA user@host" ,
319+ Volumes : []VolumeMount {
320+ {
321+ Name : "mnt" ,
322+ LocalPath : localPath ,
323+ ContainerPath : containerPath ,
324+ },
325+ },
326+ },
327+ }
328+ }
329+
330+ t .Run ("accepts root directory mounts" , func (t * testing.T ) {
331+ require .NoError (t , ValidateDevEnvConfig (newCfg ("/mnt" , "/mnt" )))
332+ })
333+
334+ t .Run ("accepts mount subpaths" , func (t * testing.T ) {
335+ require .NoError (t , ValidateDevEnvConfig (newCfg ("/mnt/data" , "/mnt/data" )))
336+ })
337+
338+ t .Run ("rejects empty localPath" , func (t * testing.T ) {
339+ err := ValidateDevEnvConfig (newCfg ("" , "/mnt" ))
340+ require .Error (t , err )
341+ assert .Contains (t , err .Error (), "LocalPath" )
342+ })
343+
344+ t .Run ("rejects empty containerPath" , func (t * testing.T ) {
345+ err := ValidateDevEnvConfig (newCfg ("/mnt" , "" ))
346+ require .Error (t , err )
347+ assert .Contains (t , err .Error (), "ContainerPath" )
348+ })
349+ }
0 commit comments