Refactor campaigns go tests
Created by: eseliger
This does some refactoring of test helpers, reduces test run time by 3s(!) in the enterprise main package, because we forgot to use our fast sleep in test that we implemented, but apparently never set the flag -count=N
with N > 1
is not working properly currently. I don't know if we ever use that or it's needed to work well, but if so I guess we could get around it with inserting repo names with ascending counts in the names or timestamps. [...], since those are essentially the only ones that cause trouble AFAICT.
In total, this gets rid of a couple redundant test helpers and reduces test runtime for the main package by roughly 3s, resolvers 4-5s and store around 1s.
Pro-tip: Best reviewed commit-by-commit. Side-note: I did one strange approach of memoizing the call to setupglobaltestdb before, that disappears in the last commit.
Before
ok github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns 9.939s 9.675s 9.979s 10.521s 9.909s 10.072s
ok github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns/resolvers 9.920s 10.040s 9.923s 11.047s 10.182s 10.391s
ok github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns/search 0.418s 0.265s 0.227s 0.230s 0.248s 0.248s
ok github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns/store 4.840s 4.845s 4.791s 4.649s 4.443s 4.795s
After
ok github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns 6.504s 6.153s 6.260s 6.370s 6.407s 6.372s
ok github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns/resolvers 5.118s 4.932s 5.011s 5.127s 5.093s 5.063s
ok github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns/search 0.225s 0.281s 0.218s 0.224s 0.228s 0.229s
ok github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns/store 3.645s 3.452s 3.358s 3.379s 3.570s 3.469s
Edit: I reverted the global db sharing for now, since it breaks -count=2
runs and I don't want to spend too much time on this right now.