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

Function TestCodeAccessConcurrentSides

internal/tool/code_access_test.go:140–178  ·  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 := 0; iteration < 12; iteration++ {
149 for _, provider := range providers {
150 workers.Add(1)
151 go func() {
152 defer workers.Done()
153 side := "new"
154 if iteration%2 == 0 {
155 side = "old"
156 }
157 args := comparisonArgs(provider.Tool().Name())
158 args["side"] = side
159 got, err := provider.Execute(context.Background(), args)
160 if err != nil {
161 test.Error(err)
162 return
163 }
164 want := side + "-marker"
165 if provider.Tool() == FileFind {
166 want = "after.txt"
167 if side == "old" {
168 want = "before.txt"
169 }
170 }
171 if !strings.Contains(got, want) {
172 test.Errorf("%s/%s: %q lacks %q", provider.Tool().Name(), side, got, want)
173 }
174 }()
175 }
176 }
177 workers.Wait()
178}
179
180func TestCodeAccessEmptyAndMissingTrees(test *testing.T) {
181 current, previous := comparisonReaders(test)

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected