Initial commit: DSH Web Manager
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package api
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestToHostPath(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
input, want string
|
||||
bad bool
|
||||
}{{"/data/workspaces/u/files", "/host/workspaces/u/files", false}, {"/data", "/host", false}, {"/data-other/x", "", true}, {"/data/../secret", "", true}, {"relative", "", true}} {
|
||||
got, err := toHostPath("/data", "/host", tc.input)
|
||||
if (err != nil) != tc.bad || got != tc.want {
|
||||
t.Fatalf("%s: %q %v", tc.input, got, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user