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

Function TestAnalysisTextUsage

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

Source from the content-addressed store, hash-verified

938}
939
940func TestAnalysisTextUsage(test *testing.T) {
941 for _, fixture := range []struct {
942 status string
943 usage behaviortask.Usage
944 want string
945 }{
946 {"partial", behaviortask.Usage{TotalTokens: 110, InputTokens: 80, OutputTokens: 25}, "Analysis tokens: ~110 (input: ~80, output: ~25)"},
947 {"failed", behaviortask.Usage{TotalTokens: 19}, "Analysis tokens: ~19"},
948 {"skipped", behaviortask.Usage{}, ""},
949 } {
950 test.Run(fixture.status, func(test *testing.T) {
951 var human bytes.Buffer
952 outputAnalysisText(&human, &analysisOutput{Report: &workflow.Report{Status: fixture.status, Usage: fixture.usage}})
953 var got string
954 for line := range strings.SplitSeq(human.String(), "\n") {
955 if strings.HasPrefix(line, "Analysis tokens:") {
956 got = line
957 break
958 }
959 }
960 if got != fixture.want {
961 test.Fatalf("got %q, want %q", got, fixture.want)
962 }
963 })
964 }
965}
966
967func TestAnalysisTextLimitPlacement(test *testing.T) {
968 for _, stop := range []llmloop.MainLoopStop{llmloop.StopMaxRounds, llmloop.StopEmptyRounds, llmloop.StopCompression, llmloop.StopTokenBudget} {

Callers

nothing calls this directly

Calls 3

outputAnalysisTextFunction · 0.85
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected