MCPcopy Create free account
hub / github.com/diillson/chatcli / TestParseStackFrame

Function TestParseStackFrame

operator/controllers/source_controller_test.go:117–143  ·  view source on GitHub ↗

--- parseStackFrame ---

(t *testing.T)

Source from the content-addressed store, hash-verified

115// --- parseStackFrame ---
116
117func TestParseStackFrame(t *testing.T) {
118 tests := []struct {
119 name string
120 frame string
121 language string
122 wantPath string
123 wantLine int
124 }{
125 {name: "go frame", frame: "pkg/server/main.go:42", language: "go", wantPath: "pkg/server/main.go", wantLine: 42},
126 {name: "go frame with trailing junk", frame: "main.go:42 +0x1b", language: "go", wantPath: "main.go", wantLine: 42},
127 {name: "go frame without line", frame: "nocolonhere", language: "go", wantPath: "", wantLine: 0},
128 {name: "java frame", frame: "at com.example.MyClass.method(MyClass.java:87)", language: "java", wantPath: "MyClass.java", wantLine: 87},
129 {name: "python frame", frame: `File "/app/handlers/views.py", line 7, in handler`, language: "python", wantPath: "/app/handlers/views.py", wantLine: 7},
130 {name: "nodejs frame", frame: "at handleRequest (/app/server.js:42:10)", language: "nodejs", wantPath: "/app/server.js", wantLine: 42},
131 {name: "unknown language", frame: "main.go:42", language: "rust", wantPath: "", wantLine: 0},
132 }
133
134 for _, tt := range tests {
135 t.Run(tt.name, func(t *testing.T) {
136 path, line := parseStackFrame(tt.frame, tt.language)
137 if path != tt.wantPath || line != tt.wantLine {
138 t.Errorf("parseStackFrame(%q, %q) = (%q, %d), want (%q, %d)",
139 tt.frame, tt.language, path, line, tt.wantPath, tt.wantLine)
140 }
141 })
142 }
143}
144
145// --- findFileInRepo ---
146

Callers

nothing calls this directly

Calls 3

parseStackFrameFunction · 0.85
ErrorfMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected