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) } } }