MCPcopy Index your code
hub / github.com/SurgeDM/Surge / TestResolveClientOutputPath

Function TestResolveClientOutputPath

cmd/utils_test.go:12–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestResolveClientOutputPath(t *testing.T) {
13 // Save original env vars to restore later
14 originalHost := os.Getenv("SURGE_HOST")
15 originalGlobalHost := globalHost
16 originalInsecureHTTP := globalInsecureHTTP
17 defer func() {
18 if err := os.Setenv("SURGE_HOST", originalHost); err != nil {
19 t.Errorf("failed to restore environment variable: %v", err)
20 }
21 globalHost = originalGlobalHost
22 globalInsecureHTTP = originalInsecureHTTP
23 }()
24
25 wd, err := os.Getwd()
26 if err != nil {
27 t.Fatalf("Failed to get current working directory: %v", err)
28 }
29
30 tests := []struct {
31 name string
32 setupHost func()
33 outputDir string
34 wantPrefix string // Used for absolute paths where exact value depends on OS/CWD
35 wantExact string
36 }{
37 {
38 name: "Remote Host Set via Env - Pass Through Empty",
39 setupHost: func() {
40 if err := os.Setenv("SURGE_HOST", "127.0.0.1:1234"); err != nil {
41 t.Fatalf("failed to set environment variable: %v", err)
42 }
43 globalHost = ""
44 },
45 outputDir: "",
46 wantExact: "",
47 },
48 {
49 name: "Remote Host Set via Global - Pass Through Exact",
50 setupHost: func() {
51 if err := os.Setenv("SURGE_HOST", ""); err != nil {
52 t.Fatalf("failed to set environment variable: %v", err)
53 }
54 globalHost = "127.0.0.1:1234"
55 },
56 outputDir: ".",
57 wantExact: ".",
58 },
59 {
60 name: "Local Execution - Empty Dir returns CWD",
61 setupHost: func() {
62 if err := os.Setenv("SURGE_HOST", ""); err != nil {
63 t.Fatalf("failed to set environment variable: %v", err)
64 }
65 globalHost = ""
66 },
67 outputDir: "",
68 wantExact: wd,
69 },

Callers

nothing calls this directly

Calls 1

resolveClientOutputPathFunction · 0.85

Tested by

no test coverage detected