Skip to content

Faster campaigns tests, part 1: the low-hanging fruit.

Administrator requested to merge mrn/faster-tests-1 into main

Created by: mrnugget

This improves on the test times reported here https://github.com/sourcegraph/sourcegraph/issues/16320#issuecomment-738681917 by 3-4 seconds.

Before:

go test ./enterprise/internal/campaigns -count=1
ok      github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns        15.346s

After:

go test ./enterprise/internal/campaigns -count=1
ok      github.com/sourcegraph/sourcegraph/enterprise/internal/campaigns        12.438s

Speed bump is relatively stable.


What's in here:

  • Rewriting one test to not use the database by introducing a tiny FakeStore that we could extend for other methods to inject a subset of the real *Store.
  • Big one: instead of calling dbtest.NewDB (twice!) to create completely new test databases (as in: CREATE DATABASE-new) we only use dbconn.Global. That means we only need to create the "setup test database" cost (roughly ~3s) once when running tests.

Merge request reports

Loading