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

Function TestCodeAccessConcurrentSides

internal/tool/code_access_test.go:140–176  ·  view source on GitHub ↗
(test *testing.T)

Source from the content-addressed store, hash-verified

138}
139
140func TestCodeAccessConcurrentSides(test *testing.T) {
141 current, previous := comparisonReaders(test)
142 access, err := NewComparisonCodeAccess(current, previous)
143 if err != nil {
144 test.Fatal(err)
145 }
146 providers := comparisonProviders(&current, access)
147 var workers sync.WaitGroup
148 for iteration := range 12 {
149 for _, provider := range providers {
150 workers.Go(func() {
151 side := "new"
152 if iteration%2 == 0 {
153 side = "old"
154 }
155 args := comparisonArgs(provider.Tool().Name())
156 args["side"] = side
157 got, err := provider.Execute(context.Background(), args)
158 if err != nil {
159 test.Error(err)
160 return
161 }
162 want := side + "-marker"
163 if provider.Tool() == FileFind {
164 want = "after.txt"
165 if side == "old" {
166 want = "before.txt"
167 }
168 }
169 if !strings.Contains(got, want) {
170 test.Errorf("%s/%s: %q lacks %q", provider.Tool().Name(), side, got, want)
171 }
172 })
173 }
174 }
175 workers.Wait()
176}
177
178func TestCodeAccessEmptyAndMissingTrees(test *testing.T) {
179 current, previous := comparisonReaders(test)

Callers

nothing calls this directly

Calls 8

comparisonReadersFunction · 0.85
NewComparisonCodeAccessFunction · 0.85
comparisonProvidersFunction · 0.85
comparisonArgsFunction · 0.85
ToolMethod · 0.65
ExecuteMethod · 0.65
NameMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected