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

Function TestCodeAccessConcurrentSides

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

Source from the content-addressed store, hash-verified

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