MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestReviewWithAnalysisHTTP

Function TestReviewWithAnalysisHTTP

cmd/opencodereview/analysis_test.go:256–484  ·  view source on GitHub ↗
(test *testing.T)

Source from the content-addressed store, hash-verified

254}
255
256func TestReviewWithAnalysisHTTP(test *testing.T) {
257 for _, fixture := range []struct {
258 name string
259 analysis bool
260 rawLogging bool
261 emptyCommit bool
262 failReview bool
263 failAnalysis bool
264 partial bool
265 budget string
266 analysisBudget string
267 analysisTokens int
268 largeBackground bool
269 maxTokensFlag string
270 mainTokens int
271 blockOutput bool
272 status string
273 wantError bool
274 }{
275 {name: "default", status: "complete"},
276 {name: "saved context limit pages analysis", analysis: true, emptyCommit: true, largeBackground: true, status: "skipped"},
277 {name: "CLI context limit overrides saved limit", analysis: true, emptyCommit: true, largeBackground: true, maxTokensFlag: "160000", status: "skipped"},
278 {name: "unlimited analysis", analysis: true, analysisTokens: 100_001, rawLogging: true, status: "complete"},
279 {name: "analysis partial self-assessment", analysis: true, partial: true, status: "complete"},
280 {name: "analysis failure", analysis: true, failAnalysis: true, status: "complete"},
281 {name: "output failure", analysis: true, failAnalysis: true, blockOutput: true, wantError: true},
282 {name: "review failure", analysis: true, failReview: true, status: "failed", wantError: true},
283 {name: "both fail", analysis: true, failReview: true, failAnalysis: true, status: "failed", wantError: true},
284 {name: "review dispatch budget", analysis: true, budget: "1", status: "failed", wantError: true},
285 {name: "budget-only partial review with analysis failure", analysis: true, failAnalysis: true, budget: "100000", mainTokens: 95000, status: "partial"},
286 {name: "final analysis submission", analysis: true, analysisBudget: "15", status: "complete"},
287 {name: "skipped review with limited analysis", analysis: true, emptyCommit: true, analysisBudget: "15", status: "skipped"},
288 } {
289 test.Run(fixture.name, func(test *testing.T) {
290 home := test.TempDir()
291 if fixture.rawLogging {
292 test.Setenv("OCR_RAW_LOGGING", "1")
293 }
294 test.Setenv("HOME", home)
295 test.Setenv("USERPROFILE", home)
296 test.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
297 repo := retryTestRepo(test)
298 if fixture.emptyCommit {
299 retryTestGit(test, repo, "commit", "--allow-empty", "-qm", "Empty change")
300 }
301 reviewer := newFakeLLM()
302 if fixture.mainTokens > 0 {
303 reviewer.mainInputTokens = fixture.mainTokens
304 }
305 if fixture.failReview {
306 reviewer.failAll()
307 }
308 var analysisCalls atomic.Int64
309 output := filepath.Join(test.TempDir(), "output.json")
310 server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
311 body, _ := io.ReadAll(request.Body)
312 if !bytes.Contains(body, []byte("submit_analysis")) {
313 request.Body = io.NopCloser(bytes.NewReader(body))

Callers

nothing calls this directly

Calls 15

ListSessionsFunction · 0.92
retryTestRepoFunction · 0.85
retryTestGitFunction · 0.85
newFakeLLMFunction · 0.85
analysisObservationsFunction · 0.85
analysisFixtureFunction · 0.85
runConfigSetFunction · 0.85
parseReviewFlagsFunction · 0.85
executeReviewContextFunction · 0.85
resolveRepoDirFunction · 0.85
failAllMethod · 0.80
ServeHTTPMethod · 0.80

Tested by

no test coverage detected