mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-09-14 19:59:52 +08:00
840f85f9bc
* test: raise statement coverage to 90% and enforce it in CI Add unit tests across the cmd and internal packages to bring total statement coverage above 90%, and gate future regressions. - Cover CLI helpers, provider TUI handlers, resume/manifest paths, and error branches in config, llm, llmloop, scan, session, agent, viewer, mcp, pathutil, and telemetry. - Raise the coverage threshold from 80% to 90% in the Makefile (COVERAGE_THRESHOLD) and in the CI "Check coverage threshold" step. - Ignore generated coverage.out and coverage.html artifacts. Total statement coverage is now 90.5%, measured consistently by both `make coverage` and the CI `go test ./...` scope. * test: widen statement coverage margin with environment-independent unit tests Add table-driven unit tests for pure, environment-independent functions to raise the statement-coverage safety margin above the 90% threshold: - session.ResumeState.ValidateScanOptions (70% -> 100%) - rules.SystemRule.UnmarshalJSON error branches (71% -> 82%) - llmloop.stripMarkdownFences no-newline branch (82% -> 100%) - diff.firstLine empty/blank-input branch - diff.extractCodeBlock missing-newline and no-closing-fence branches - main.truncate n<=1 and normalization branches - agent.Agent nil-receiver accessor guards
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
// SPDX-License-Identifier: Apache-2.0
|
|
// Copyright 2026 alibaba/open-code-review Contributors
|
|
|
|
package session
|
|
|
|
import "testing"
|
|
|
|
func TestFinalManifest(t *testing.T) {
|
|
// Nil receiver must not panic.
|
|
var nilSH *SessionHistory
|
|
if got := nilSH.FinalManifest(); got != nil {
|
|
t.Errorf("nil-receiver FinalManifest() = %v, want nil", got)
|
|
}
|
|
|
|
// A session with no frozen manifest (legacy/scan) returns nil.
|
|
sh := &SessionHistory{}
|
|
if got := sh.FinalManifest(); got != nil {
|
|
t.Errorf("FinalManifest() with no manifest = %v, want nil", got)
|
|
}
|
|
|
|
// SetFinalManifest is a no-op on a nil receiver.
|
|
nilSH.SetFinalManifest(&RunManifest{RunID: "ignored"})
|
|
|
|
// After storing, FinalManifest returns a cloned copy carrying the data.
|
|
sh.SetFinalManifest(&RunManifest{RunID: "run-123", Operation: "review"})
|
|
got := sh.FinalManifest()
|
|
if got == nil {
|
|
t.Fatal("FinalManifest() after set = nil, want value")
|
|
}
|
|
if got.RunID != "run-123" || got.Operation != "review" {
|
|
t.Errorf("FinalManifest() = %+v, want RunID=run-123 Operation=review", got)
|
|
}
|
|
}
|