package app import ( "os" "path/filepath" "testing" ) // A remote location names a directory on another host, so the CLI passes it // to the daemon as typed. Resolving it against the local directory would // start the session in a local path that only looks like it. func TestAbsoluteWorkspaceResolvesOnlyLocalPaths(t *testing.T) { cwd, err := os.Getwd() if err != nil { t.Fatal(err) } for _, tc := range []struct{ in, want string }{ {"box:/srv/cli", "box:/srv/cli"}, {"mayer@box:/srv/cli", "mayer@box:/srv/cli"}, {"[::1]:/srv", "[::1]:/srv"}, {"/srv/local", "/srv/local"}, {"relative", filepath.Join(cwd, "relative")}, {"dir/with:/colon", filepath.Join(cwd, "dir/with:/colon")}, } { if got := absoluteWorkspace(tc.in); got != tc.want { t.Errorf("absoluteWorkspace(%q) = %q, want %q", tc.in, got, tc.want) } } }