mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:12:02 +00:00
all: use observation.TestContextTB instead of TestContext (#61751)
observation.TestContextTB is better to use since your logs will be scoped to your test and it will use a more pedantic prometheus registry. To be honest TestContext should be removed but this is the first step. This is a mechanical change. I replaced "&observation.TestContext" with "observation.TestContextTB(t)". I then undid the change each time it caused a compilation error (was only a handful of times). Test Plan: go test
This commit is contained in:
parent
4d107d894e
commit
e9d0d57d81
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
observationContext := &observation.TestContext
|
||||
observationContext := observation.TestContextTB(t)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -56,7 +56,7 @@ func TestNew(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_Exists(t *testing.T) {
|
||||
observationContext := &observation.TestContext
|
||||
observationContext := observation.TestContextTB(t)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -150,7 +150,7 @@ func TestClient_Exists(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_Get(t *testing.T) {
|
||||
observationContext := &observation.TestContext
|
||||
observationContext := observation.TestContextTB(t)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
|
||||
func TestCommand_Run(t *testing.T) {
|
||||
internalLogger := logtest.Scoped(t)
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@ -30,7 +30,7 @@ func TestKubernetesCommand_CreateJob(t *testing.T) {
|
||||
cmd := &command.KubernetesCommand{
|
||||
Logger: logtest.Scoped(t),
|
||||
Clientset: clientset,
|
||||
Operations: command.NewOperations(&observation.TestContext),
|
||||
Operations: command.NewOperations(observation.TestContextTB(t)),
|
||||
}
|
||||
|
||||
job := &batchv1.Job{}
|
||||
@ -50,7 +50,7 @@ func TestKubernetesCommand_DeleteJob(t *testing.T) {
|
||||
cmd := &command.KubernetesCommand{
|
||||
Logger: logtest.Scoped(t),
|
||||
Clientset: clientset,
|
||||
Operations: command.NewOperations(&observation.TestContext),
|
||||
Operations: command.NewOperations(observation.TestContextTB(t)),
|
||||
}
|
||||
|
||||
job := &batchv1.Job{ObjectMeta: metav1.ObjectMeta{Name: "my-job"}}
|
||||
@ -73,7 +73,7 @@ func TestKubernetesCommand_CreateSecrets(t *testing.T) {
|
||||
cmd := &command.KubernetesCommand{
|
||||
Logger: logtest.Scoped(t),
|
||||
Clientset: clientset,
|
||||
Operations: command.NewOperations(&observation.TestContext),
|
||||
Operations: command.NewOperations(observation.TestContextTB(t)),
|
||||
}
|
||||
|
||||
secrets := map[string]string{
|
||||
@ -99,7 +99,7 @@ func TestKubernetesCommand_DeleteSecret(t *testing.T) {
|
||||
cmd := &command.KubernetesCommand{
|
||||
Logger: logtest.Scoped(t),
|
||||
Clientset: clientset,
|
||||
Operations: command.NewOperations(&observation.TestContext),
|
||||
Operations: command.NewOperations(observation.TestContextTB(t)),
|
||||
}
|
||||
|
||||
secrets := map[string]string{
|
||||
@ -124,7 +124,7 @@ func TestKubernetesCommand_CreateJobPVC(t *testing.T) {
|
||||
cmd := &command.KubernetesCommand{
|
||||
Logger: logtest.Scoped(t),
|
||||
Clientset: clientset,
|
||||
Operations: command.NewOperations(&observation.TestContext),
|
||||
Operations: command.NewOperations(observation.TestContextTB(t)),
|
||||
}
|
||||
|
||||
err := cmd.CreateJobPVC(context.Background(), "my-namespace", "my-pvc", resource.MustParse("1Gi"))
|
||||
@ -142,7 +142,7 @@ func TestKubernetesCommand_DeleteJobPVC(t *testing.T) {
|
||||
cmd := &command.KubernetesCommand{
|
||||
Logger: logtest.Scoped(t),
|
||||
Clientset: clientset,
|
||||
Operations: command.NewOperations(&observation.TestContext),
|
||||
Operations: command.NewOperations(observation.TestContextTB(t)),
|
||||
}
|
||||
|
||||
err := cmd.CreateJobPVC(context.Background(), "my-namespace", "my-pvc", resource.MustParse("1Gi"))
|
||||
@ -509,7 +509,7 @@ func TestKubernetesCommand_WaitForPodToSucceed(t *testing.T) {
|
||||
cmd := &command.KubernetesCommand{
|
||||
Logger: logtest.Scoped(t),
|
||||
Clientset: clientset,
|
||||
Operations: command.NewOperations(&observation.TestContext),
|
||||
Operations: command.NewOperations(observation.TestContextTB(t)),
|
||||
}
|
||||
|
||||
pod, err := cmd.WaitForPodToSucceed(
|
||||
|
||||
@ -145,7 +145,7 @@ func TestHandler_Handle_Legacy(t *testing.T) {
|
||||
// No runtime is configured.
|
||||
// Will go away once firecracker is implemented.
|
||||
internalLogger := logtest.Scoped(t)
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -418,7 +418,7 @@ func TestHandler_Handle_Legacy(t *testing.T) {
|
||||
|
||||
func TestHandler_Handle(t *testing.T) {
|
||||
internalLogger := logtest.Scoped(t)
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@ -19,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestFirecrackerRunner_Setup(t *testing.T) {
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -331,7 +331,7 @@ const defaultCNIConfig = `
|
||||
func TestFirecrackerRunner_Teardown(t *testing.T) {
|
||||
cmd := runner.NewMockCommand()
|
||||
logger := runner.NewMockLogger()
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
firecrackerRunner := runner.NewFirecrackerRunner(cmd, logger, "/dev", "test", runner.FirecrackerOptions{}, types.DockerAuthConfig{}, operations)
|
||||
|
||||
cmd.RunFunc.PushReturn(nil)
|
||||
@ -369,7 +369,7 @@ func matchCmd(key string) func(spec command.Spec) bool {
|
||||
func TestFirecrackerRunner_Run(t *testing.T) {
|
||||
cmd := runner.NewMockCommand()
|
||||
logger := runner.NewMockLogger()
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
options := runner.FirecrackerOptions{
|
||||
DockerOptions: command.DockerOptions{
|
||||
ConfigPath: "/docker/config",
|
||||
|
||||
@ -116,7 +116,7 @@ func TestKubernetesRunner_Run(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
clientset := fake.NewSimpleClientset()
|
||||
cmd := &command.KubernetesCommand{Logger: logtest.Scoped(t), Clientset: clientset, Operations: command.NewOperations(&observation.TestContext)}
|
||||
cmd := &command.KubernetesCommand{Logger: logtest.Scoped(t), Clientset: clientset, Operations: command.NewOperations(observation.TestContextTB(t))}
|
||||
logger := runner.NewMockLogger()
|
||||
logEntry := runner.NewMockLogEntry()
|
||||
teardownLogEntry := runner.NewMockLogEntry()
|
||||
@ -181,7 +181,7 @@ func TestKubernetesRunner_Run(t *testing.T) {
|
||||
|
||||
func TestKubernetesRunner_Teardown(t *testing.T) {
|
||||
clientset := fake.NewSimpleClientset()
|
||||
cmd := &command.KubernetesCommand{Logger: logtest.Scoped(t), Clientset: clientset, Operations: command.NewOperations(&observation.TestContext)}
|
||||
cmd := &command.KubernetesCommand{Logger: logtest.Scoped(t), Clientset: clientset, Operations: command.NewOperations(observation.TestContextTB(t))}
|
||||
logger := runner.NewMockLogger()
|
||||
logEntry := runner.NewMockLogEntry()
|
||||
logger.LogEntryFunc.PushReturn(logEntry)
|
||||
|
||||
@ -18,7 +18,7 @@ func TestDockerRuntime_Name(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDockerRuntime_NewRunnerSpecs(t *testing.T) {
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@ -18,7 +18,7 @@ func TestFirecrackerRuntime_Name(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFirecrackerRuntime_NewRunnerSpecs(t *testing.T) {
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@ -18,7 +18,7 @@ func TestKubernetesRuntime_Name(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKubernetesRuntime_NewRunnerSpecs(t *testing.T) {
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@ -18,7 +18,7 @@ func TestShellRuntime_Name(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShellRuntime_NewRunnerSpecs(t *testing.T) {
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNewDockerWorkspace(t *testing.T) {
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNewFirecrackerWorkspace(t *testing.T) {
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@ -26,7 +26,7 @@ func TestNewKubernetesWorkspace(t *testing.T) {
|
||||
os.Unsetenv("KUBERNETES_SERVICE_HOST")
|
||||
})
|
||||
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -520,7 +520,7 @@ func TestNewKubernetesWorkspace_SingleJob(t *testing.T) {
|
||||
cmd := workspace.NewMockCommand()
|
||||
logger := workspace.NewMockLogger()
|
||||
|
||||
operations := command.NewOperations(&observation.TestContext)
|
||||
operations := command.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
ws, err := workspace.NewKubernetesWorkspace(
|
||||
context.Background(),
|
||||
|
||||
@ -209,7 +209,7 @@ func TestSnippetAttributionReactsToSiteConfigChanges(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
g := gitserver.NewClient("graphql.test")
|
||||
var enterpriseServices enterprise.Services
|
||||
require.NoError(t, guardrails.Init(ctx, &observation.TestContext, db, codeintel.Services{}, confMock, &enterpriseServices))
|
||||
require.NoError(t, guardrails.Init(ctx, observation.TestContextTB(t), db, codeintel.Services{}, confMock, &enterpriseServices))
|
||||
s, err := graphqlbackend.NewSchema(db, g, []graphqlbackend.OptionalResolver{{GuardrailsResolver: enterpriseServices.OptionalResolver.GuardrailsResolver}})
|
||||
require.NoError(t, err)
|
||||
// Same query runs in every test:
|
||||
|
||||
@ -36,7 +36,7 @@ func TestFileHandler_ServeHTTP(t *testing.T) {
|
||||
modifiedTime, err := time.Parse("2006-01-02 15:04:05.999999999 -0700 MST", modifiedTimeString)
|
||||
require.NoError(t, err)
|
||||
|
||||
operations := httpapi.NewOperations(&observation.TestContext)
|
||||
operations := httpapi.NewOperations(observation.TestContextTB(t))
|
||||
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
@ -33,7 +33,7 @@ func TestBatchChangeConnectionResolver(t *testing.T) {
|
||||
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
|
||||
bstore := bstore.New(db, &observation.TestContext, nil)
|
||||
bstore := bstore.New(db, observation.TestContextTB(t), nil)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
@ -189,7 +189,7 @@ func TestBatchChangesListing(t *testing.T) {
|
||||
|
||||
orgID := bt.CreateTestOrg(t, db, "org").ID
|
||||
|
||||
store := bstore.New(db, &observation.TestContext, nil)
|
||||
store := bstore.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
r := &Resolver{store: store}
|
||||
s, err := newSchema(db, r)
|
||||
|
||||
@ -39,7 +39,7 @@ func TestBatchChangeResolver(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
batchSpec := &btypes.BatchSpec{
|
||||
RawSpec: bt.TestRawBatchSpec,
|
||||
@ -155,7 +155,7 @@ func TestBatchChangeResolver_BatchSpecs(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
s, err := newSchema(db, &Resolver{store: bstore})
|
||||
if err != nil {
|
||||
|
||||
@ -42,7 +42,7 @@ func TestBatchSpecResolver(t *testing.T) {
|
||||
ctx := actor.WithInternalActor(context.Background())
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
@ -276,7 +276,7 @@ func TestBatchSpecResolver_BatchSpecCreatedFromRaw(t *testing.T) {
|
||||
|
||||
rs, extSvc := bt.CreateTestRepos(t, ctx, db, 3)
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
svc := service.New(bstore)
|
||||
spec, err := svc.CreateBatchSpecFromRaw(userCtx, service.CreateBatchSpecFromRawOpts{
|
||||
@ -507,7 +507,7 @@ func TestBatchSpecResolver_Files(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
resolver := batchSpecResolver{
|
||||
store: bstore,
|
||||
|
||||
@ -29,7 +29,7 @@ func TestBatchSpecWorkspaceFileConnectionResolver(t *testing.T) {
|
||||
ctx := actor.WithInternalActor(context.Background())
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
specID, err := createBatchSpec(t, db, ctx, bstore)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ func TestBatchSpecWorkspaceResolver(t *testing.T) {
|
||||
ctx := actor.WithInternalActor(context.Background())
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
repo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
|
||||
repoID := graphqlbackend.MarshalRepositoryID(repo.ID)
|
||||
|
||||
@ -33,7 +33,7 @@ func TestBulkOperationConnectionResolver(t *testing.T) {
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
batchSpec := bt.CreateBatchSpec(t, ctx, bstore, "test", userID, 0)
|
||||
batchChange := bt.CreateBatchChange(t, ctx, bstore, "test", userID, batchSpec.ID)
|
||||
|
||||
@ -35,7 +35,7 @@ func TestBulkOperationResolver(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
batchSpec := bt.CreateBatchSpec(t, ctx, bstore, "test", userID, 0)
|
||||
batchChange := bt.CreateBatchChange(t, ctx, bstore, "test", userID, batchSpec.ID)
|
||||
|
||||
@ -39,7 +39,7 @@ func TestChangesetApplyPreviewConnectionResolver(t *testing.T) {
|
||||
|
||||
userID := bt.CreateTestUser(t, db, false).ID
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
batchSpec := &btypes.BatchSpec{
|
||||
UserID: userID,
|
||||
|
||||
@ -39,7 +39,7 @@ func TestChangesetApplyPreviewResolver(t *testing.T) {
|
||||
|
||||
userID := bt.CreateTestUser(t, db, false).ID
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
// Create a batch spec for the target batch change.
|
||||
oldBatchSpec := &btypes.BatchSpec{
|
||||
@ -270,7 +270,7 @@ func TestChangesetApplyPreviewResolverWithPublicationStates(t *testing.T) {
|
||||
|
||||
userID := bt.CreateTestUser(t, db, false).ID
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ func TestChangesetConnectionResolver(t *testing.T) {
|
||||
|
||||
userID := bt.CreateTestUser(t, db, false).ID
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
|
||||
@ -129,7 +129,7 @@ func TestChangesetCountsOverTimeIntegration(t *testing.T) {
|
||||
})
|
||||
defer mockState.Unmock()
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
if err := bstore.CreateSiteCredential(ctx,
|
||||
&btypes.SiteCredential{
|
||||
|
||||
@ -36,7 +36,7 @@ func TestChangesetEventConnectionResolver(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ func TestChangesetSpecConnectionResolver(t *testing.T) {
|
||||
|
||||
userID := bt.CreateTestUser(t, db, false).ID
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
batchSpec := &btypes.BatchSpec{
|
||||
UserID: userID,
|
||||
|
||||
@ -35,7 +35,7 @@ func TestChangesetSpecResolver(t *testing.T) {
|
||||
|
||||
userID := bt.CreateTestUser(t, db, false).ID
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
// Creating user with matching email to the changeset spec author.
|
||||
|
||||
@ -40,7 +40,7 @@ func TestChangesetResolver(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ func TestCodeHostConnectionResolver(t *testing.T) {
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
userAPIID := string(graphqlbackend.MarshalUserID(userID))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
ghRepo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
glRepos, _ := bt.CreateGitlabTestRepos(t, ctx, db, 1)
|
||||
|
||||
@ -49,7 +49,7 @@ func TestPermissionLevels(t *testing.T) {
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
key := et.TestKey{}
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, key)
|
||||
bstore := store.New(db, observation.TestContextTB(t), key)
|
||||
sr := New(db, bstore, gitserver.NewMockClient(), logger)
|
||||
s, err := newSchema(db, sr)
|
||||
if err != nil {
|
||||
@ -1361,7 +1361,7 @@ func TestRepositoryPermissions(t *testing.T) {
|
||||
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
gitserverClient := gitserver.NewMockClient()
|
||||
sr := &Resolver{store: bstore}
|
||||
s, err := newSchema(db, sr)
|
||||
|
||||
@ -52,7 +52,7 @@ func TestNullIDResilience(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
sr := New(db, store.New(db, &observation.TestContext, nil), gitserver.NewMockClient(), logger)
|
||||
sr := New(db, store.New(db, observation.TestContextTB(t), nil), gitserver.NewMockClient(), logger)
|
||||
|
||||
s, err := newSchema(db, sr)
|
||||
if err != nil {
|
||||
@ -149,7 +149,7 @@ func TestCreateBatchSpec(t *testing.T) {
|
||||
|
||||
unauthorizedUser := bt.CreateTestUser(t, db, false)
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
@ -348,7 +348,7 @@ func TestCreateBatchSpecFromRaw(t *testing.T) {
|
||||
|
||||
unauthorizedUser := bt.CreateTestUser(t, db, false)
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
r := &Resolver{store: bstore}
|
||||
s, err := newSchema(db, r)
|
||||
@ -482,7 +482,7 @@ func TestCreateChangesetSpec(t *testing.T) {
|
||||
|
||||
unauthorizedUser := bt.CreateTestUser(t, db, false)
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
@ -576,7 +576,7 @@ func TestCreateChangesetSpecs(t *testing.T) {
|
||||
|
||||
unauthorizedUser := bt.CreateTestUser(t, db, false)
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
@ -688,7 +688,7 @@ func TestApplyBatchChange(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
@ -860,7 +860,7 @@ func TestCreateEmptyBatchChange(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
r := &Resolver{store: bstore}
|
||||
s, err := newSchema(db, r)
|
||||
@ -968,7 +968,7 @@ func TestUpsertEmptyBatchChange(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
r := &Resolver{store: bstore}
|
||||
s, err := newSchema(db, r)
|
||||
@ -1064,7 +1064,7 @@ func TestCreateBatchChange(t *testing.T) {
|
||||
|
||||
unauthorizedUser := bt.CreateTestUser(t, db, false)
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
batchSpec := &btypes.BatchSpec{
|
||||
RawSpec: bt.TestRawBatchSpec,
|
||||
@ -1176,7 +1176,7 @@ func TestApplyOrCreateBatchSpecWithPublicationStates(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
@ -1372,7 +1372,7 @@ func TestApplyBatchChangeWithLicenseFail(t *testing.T) {
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
repoStore := database.ReposWith(logger, bstore)
|
||||
esStore := database.ExternalServicesWith(logger, bstore)
|
||||
|
||||
@ -1525,7 +1525,7 @@ func TestMoveBatchChange(t *testing.T) {
|
||||
orgName := "move-batch-change-test"
|
||||
orgID := bt.CreateTestOrg(t, db, orgName).ID
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
batchSpec := &btypes.BatchSpec{
|
||||
RawSpec: bt.TestRawBatchSpec,
|
||||
@ -1828,7 +1828,7 @@ func TestCreateBatchChangesCredential(t *testing.T) {
|
||||
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
r := &Resolver{store: bstore}
|
||||
s, err := newSchema(db, r)
|
||||
@ -1959,7 +1959,7 @@ func TestDeleteBatchChangesCredential(t *testing.T) {
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
ctx = actor.WithActor(ctx, actor.FromUser(userID))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
authenticator := &auth.OAuthBearerToken{Token: "SOSECRET"}
|
||||
userCred, err := bstore.UserCredentials().Create(ctx, database.UserCredentialScope{
|
||||
@ -2044,7 +2044,7 @@ func TestCreateChangesetComments(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
// We give this user the `BATCH_CHANGES#WRITE` permission so they're authorized
|
||||
@ -2164,7 +2164,7 @@ func TestReenqueueChangesets(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
// We give this user the `BATCH_CHANGES#WRITE` permission so they're authorized
|
||||
@ -2293,7 +2293,7 @@ func TestMergeChangesets(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
// We give this user the `BATCH_CHANGES#WRITE` permission so they're authorized
|
||||
@ -2423,7 +2423,7 @@ func TestCloseChangesets(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
// We give this user the `BATCH_CHANGES#WRITE` permission so they're authorized
|
||||
@ -2553,7 +2553,7 @@ func TestPublishChangesets(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
// We give this user the `BATCH_CHANGES#WRITE` permission so they're authorized
|
||||
@ -2704,7 +2704,7 @@ func TestCheckBatchChangesCredential(t *testing.T) {
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
ctx = actor.WithActor(ctx, actor.FromUser(userID))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
authenticator := &auth.OAuthBearerToken{Token: "SOSECRET"}
|
||||
userCred, err := bstore.UserCredentials().Create(ctx, database.UserCredentialScope{
|
||||
@ -2800,7 +2800,7 @@ func TestMaxUnlicensedChangesets(t *testing.T) {
|
||||
var response struct{ MaxUnlicensedChangesets int32 }
|
||||
actorCtx := actor.WithActor(context.Background(), actor.FromUser(userID))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
r := &Resolver{store: bstore}
|
||||
s, err := newSchema(db, r)
|
||||
require.NoError(t, err)
|
||||
@ -2824,7 +2824,7 @@ func TestListBatchSpecs(t *testing.T) {
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
userID := user.ID
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
batchSpecs := make([]*btypes.BatchSpec, 0, 10)
|
||||
|
||||
@ -2891,7 +2891,7 @@ func TestGetChangesetsByIDs(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
bstore := store.New(db, &observation.TestContext, nil)
|
||||
bstore := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
// We give this user the `BATCH_CHANGES#WRITE` permission so they're authorized
|
||||
|
||||
@ -400,7 +400,7 @@ func bitbucketCloudTestSetup(t *testing.T, sqlDB *sql.DB) *bstore.Store {
|
||||
// transactions within the test.
|
||||
db := database.NewDBWith(logger, basestore.NewWithHandle(&nestedTx{basestore.NewHandleWithTx(tx, sql.TxOptions{})}))
|
||||
|
||||
return bstore.NewWithClock(db, &observation.TestContext, nil, clock.Now)
|
||||
return bstore.NewWithClock(db, observation.TestContextTB(t), nil, clock.Now)
|
||||
}
|
||||
|
||||
// createBitbucketCloudExternalService creates a mock Bitbucket Cloud service
|
||||
|
||||
@ -100,7 +100,7 @@ func testBitbucketServerWebhook(db database.DB, userID int32) func(*testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
s := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
s := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
if err := s.CreateSiteCredential(ctx, &btypes.SiteCredential{
|
||||
ExternalServiceType: bitbucketRepo.ExternalRepo.ServiceType,
|
||||
|
||||
@ -98,7 +98,7 @@ func testGitHubWebhook(db database.DB, userID int32) func(*testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
s := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
s := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
if err := s.CreateSiteCredential(ctx, &btypes.SiteCredential{
|
||||
ExternalServiceType: githubRepo.ExternalRepo.ServiceType,
|
||||
ExternalServiceID: githubRepo.ExternalRepo.ServiceID,
|
||||
|
||||
@ -503,7 +503,7 @@ func testGitLabWebhook(db *sql.DB) func(*testing.T) {
|
||||
s := gitLabTestSetup(t, db)
|
||||
h := NewGitLabWebhook(s, gsClient, logger)
|
||||
db := database.NewDBWith(logger, basestore.NewWithHandle(&brokenDB{errors.New("foo")}))
|
||||
h.Store = bstore.NewWithClock(db, &observation.TestContext, nil, s.Clock())
|
||||
h.Store = bstore.NewWithClock(db, observation.TestContextTB(t), nil, s.Clock())
|
||||
|
||||
es, err := h.getExternalServiceFromRawID(ctx, "12345")
|
||||
if es != nil {
|
||||
@ -560,7 +560,7 @@ func testGitLabWebhook(db *sql.DB) func(*testing.T) {
|
||||
|
||||
// We can induce an error with a broken database connection.
|
||||
db := database.NewDBWith(logger, basestore.NewWithHandle(&brokenDB{errors.New("foo")}))
|
||||
h.Store = bstore.NewWithClock(db, &observation.TestContext, nil, s.Clock())
|
||||
h.Store = bstore.NewWithClock(db, observation.TestContextTB(t), nil, s.Clock())
|
||||
|
||||
err := h.handleEvent(ctx, db, gitLabURL, event)
|
||||
require.Error(t, err)
|
||||
@ -577,7 +577,7 @@ func testGitLabWebhook(db *sql.DB) func(*testing.T) {
|
||||
|
||||
// We can induce an error with a broken database connection.
|
||||
db := database.NewDBWith(logger, basestore.NewWithHandle(&brokenDB{errors.New("foo")}))
|
||||
h.Store = bstore.NewWithClock(db, &observation.TestContext, nil, s.Clock())
|
||||
h.Store = bstore.NewWithClock(db, observation.TestContextTB(t), nil, s.Clock())
|
||||
|
||||
err := h.handleEvent(ctx, db, gitLabURL, event)
|
||||
require.Error(t, err)
|
||||
@ -683,7 +683,7 @@ func testGitLabWebhook(db *sql.DB) func(*testing.T) {
|
||||
// Again, we're going to set up a poisoned store database that will
|
||||
// error if a transaction is started.
|
||||
s := gitLabTestSetup(t, db)
|
||||
store := bstore.NewWithClock(database.NewDBWith(logger, basestore.NewWithHandle(&noNestingTx{s.Handle()})), &observation.TestContext, nil, s.Clock())
|
||||
store := bstore.NewWithClock(database.NewDBWith(logger, basestore.NewWithHandle(&noNestingTx{s.Handle()})), observation.TestContextTB(t), nil, s.Clock())
|
||||
h := NewGitLabWebhook(store, gsClient, logger)
|
||||
|
||||
t.Run("missing merge request", func(t *testing.T) {
|
||||
@ -870,7 +870,7 @@ func gitLabTestSetup(t *testing.T, sqlDB *sql.DB) *bstore.Store {
|
||||
|
||||
// Note that tx is wrapped in nestedTx to effectively neuter further use of
|
||||
// transactions within the test.
|
||||
return bstore.NewWithClock(db, &observation.TestContext, nil, c.Now)
|
||||
return bstore.NewWithClock(db, observation.TestContextTB(t), nil, c.Now)
|
||||
}
|
||||
|
||||
// assertBodyIncludes checks for a specific substring within the given response
|
||||
|
||||
@ -72,7 +72,7 @@ UPDATE gitserver_repos SET repo_size_bytes = 5 where repo_id = 3;
|
||||
t.Fatalf("unexpected error while inserting test data: %s", err)
|
||||
}
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
cleanupRepos(
|
||||
actor.WithInternalActor(context.Background()),
|
||||
@ -136,7 +136,7 @@ func TestCleanupInactive(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
cleanupRepos(
|
||||
@ -178,7 +178,7 @@ func TestCleanupWrongShard(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
cleanupRepos(
|
||||
@ -218,7 +218,7 @@ func TestCleanupWrongShard(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
cleanupRepos(
|
||||
@ -258,7 +258,7 @@ func TestCleanupWrongShard(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
cleanupRepos(
|
||||
@ -334,7 +334,7 @@ func TestGitGCAuto(t *testing.T) {
|
||||
t.Fatalf("expected git to report objects but none found")
|
||||
}
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
cleanupRepos(
|
||||
@ -464,7 +464,7 @@ func TestCleanupExpired(t *testing.T) {
|
||||
return "done", nil
|
||||
}
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
cleanupRepos(
|
||||
@ -531,7 +531,7 @@ func TestCleanup_RemoveNonExistentRepos(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
repoExists, repoNotExists := initRepos(root)
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
cleanupRepos(
|
||||
@ -563,7 +563,7 @@ func TestCleanup_RemoveNonExistentRepos(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
repoExists, repoNotExists := initRepos(root)
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
cleanupRepos(
|
||||
@ -718,7 +718,7 @@ func TestCleanupOldLocks(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
cleanupRepos(
|
||||
@ -885,7 +885,7 @@ func isEmptyDir(path string) (bool, error) {
|
||||
func TestFreeUpSpace(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
root := t.TempDir()
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
t.Run("no error if no space requested and no repos", func(t *testing.T) {
|
||||
if err := freeUpSpace(context.Background(), logger, newMockedGitserverDB(), fs, "test-gitserver", &fakeDiskUsage{}, 10, 0); err != nil {
|
||||
|
||||
@ -53,7 +53,7 @@ func TestClone(t *testing.T) {
|
||||
lock := NewMockRepositoryLock()
|
||||
locker.TryAcquireFunc.SetDefaultReturn(lock, true)
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, reposDir)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), reposDir)
|
||||
require.NoError(t, fs.Initialize())
|
||||
getRemoteURLFunc := func(_ context.Context, name api.RepoName) (string, error) { //nolint:unparam
|
||||
require.Equal(t, repo, name)
|
||||
@ -169,7 +169,7 @@ func TestClone_Fail(t *testing.T) {
|
||||
lock := NewMockRepositoryLock()
|
||||
locker.TryAcquireFunc.SetDefaultReturn(lock, true)
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, reposDir)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), reposDir)
|
||||
require.NoError(t, fs.Initialize())
|
||||
getRemoteURLFunc := func(_ context.Context, name api.RepoName) (string, error) { //nolint:unparam
|
||||
require.Equal(t, repo, name)
|
||||
|
||||
@ -72,7 +72,7 @@ func TestClient_ResolveRevision(t *testing.T) {
|
||||
db := newMockDB()
|
||||
ctx := context.Background()
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, filepath.Join(root, "repos"))
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), filepath.Join(root, "repos"))
|
||||
require.NoError(t, fs.Initialize())
|
||||
getRemoteURLFunc := func(_ context.Context, name api.RepoName) (string, error) { //nolint:unparam
|
||||
return remote, nil
|
||||
|
||||
@ -80,7 +80,7 @@ func InitGitserver() {
|
||||
})
|
||||
db.ReposFunc.SetDefaultReturn(r)
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, filepath.Join(root, "repos"))
|
||||
fs := gitserverfs.New(observation.TestContextTB(&t), filepath.Join(root, "repos"))
|
||||
require.NoError(&t, fs.Initialize())
|
||||
getRemoteURLFunc := func(_ context.Context, name api.RepoName) (string, error) { //nolint:unparam // context is unused but required by the interface, error is not used in this test
|
||||
return filepath.Join(root, "remotes", string(name)), nil
|
||||
|
||||
@ -115,7 +115,7 @@ func TestExecRequest(t *testing.T) {
|
||||
db := dbmocks.NewMockDB()
|
||||
gr := dbmocks.NewMockGitserverRepoStore()
|
||||
db.GitserverReposFunc.SetDefaultReturn(gr)
|
||||
fs := gitserverfs.New(&observation.TestContext, t.TempDir())
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), t.TempDir())
|
||||
require.NoError(t, fs.Initialize())
|
||||
s := NewServer(&ServerOpts{
|
||||
Logger: logtest.Scoped(t),
|
||||
@ -1148,7 +1148,7 @@ func TestServer_IsRepoCloneable_InternalActor(t *testing.T) {
|
||||
|
||||
isCloneableCalled := false
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, t.TempDir())
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), t.TempDir())
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
s := NewServer(&ServerOpts{
|
||||
|
||||
@ -136,7 +136,7 @@ func TestNoMaliciousFiles(t *testing.T) {
|
||||
|
||||
cacheDir := filepath.Join(dir, "cache")
|
||||
s := jvmPackagesSyncer{
|
||||
coursier: coursier.NewCoursierHandle(&observation.TestContext, cacheDir),
|
||||
coursier: coursier.NewCoursierHandle(observation.TestContextTB(t), cacheDir),
|
||||
config: &schema.JVMPackagesConnection{Maven: schema.Maven{Dependencies: []string{}}},
|
||||
fetch: func(ctx context.Context, config *schema.JVMPackagesConnection, dependency *reposource.MavenVersionedPackage) (sourceCodeJarPath string, err error) {
|
||||
jarPath := path.Join(dir, "sampletext.zip")
|
||||
@ -219,7 +219,7 @@ func TestJVMCloneCommand(t *testing.T) {
|
||||
|
||||
depsSvc := dependencies.TestService(database.NewDB(logger, dbtest.NewDB(t)))
|
||||
cacheDir := filepath.Join(dir, "cache")
|
||||
fs := gitserverfs.New(&observation.TestContext, dir)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), dir)
|
||||
require.NoError(t, fs.Initialize())
|
||||
s := NewJVMPackagesSyncer(&schema.JVMPackagesConnection{Maven: schema.Maven{Dependencies: []string{}}}, depsSvc, testGetRemoteURLSource, cacheDir, fs).(*vcsPackagesSyncer)
|
||||
bareGitDirectory := path.Join(dir, "git")
|
||||
|
||||
@ -121,7 +121,7 @@ func TestNpmCloneCommand(t *testing.T) {
|
||||
|
||||
depsSvc := dependencies.TestService(database.NewDB(logger, dbtest.NewDB(t)))
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, dir)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), dir)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
s := NewNpmPackagesSyncer(
|
||||
|
||||
@ -39,7 +39,7 @@ func TestVcsDependenciesSyncer_Fetch(t *testing.T) {
|
||||
depsService := &fakeDepsService{deps: map[reposource.PackageName]dependencies.PackageRepoReference{}}
|
||||
|
||||
root := t.TempDir()
|
||||
fs := gitserverfs.New(&observation.TestContext, root)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), root)
|
||||
require.NoError(t, fs.Initialize())
|
||||
remoteURL := &vcs.URL{URL: url.URL{Path: "fake/foo"}}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ func TestGetVCSSyncer(t *testing.T) {
|
||||
}
|
||||
tempCoursierCacheDir := filepath.Join(tempReposDir, "coursier")
|
||||
|
||||
fs := gitserverfs.New(&observation.TestContext, tempReposDir)
|
||||
fs := gitserverfs.New(observation.TestContextTB(t), tempReposDir)
|
||||
require.NoError(t, fs.Initialize())
|
||||
|
||||
repo := api.RepoName("foo/bar")
|
||||
|
||||
@ -78,7 +78,7 @@ func TestHandler(t *testing.T) {
|
||||
gitserverClient := NewMockGitserverClient()
|
||||
gitserverClient.FetchTarFunc.SetDefaultHook(gitserver.CreateTestFetchTarFunc(files))
|
||||
|
||||
symbolParser := parser.NewParser(&observation.TestContext, parserPool, fetcher.NewRepositoryFetcher(&observation.TestContext, gitserverClient, 1000, 1_000_000), 0, 10)
|
||||
symbolParser := parser.NewParser(observation.TestContextTB(t), parserPool, fetcher.NewRepositoryFetcher(observation.TestContextTB(t), gitserverClient, 1000, 1_000_000), 0, 10)
|
||||
databaseWriter := writer.NewDatabaseWriter(observation.TestContextTB(t), tmpDir, gitserverClient, symbolParser, semaphore.NewWeighted(1))
|
||||
cachedDatabaseWriter := writer.NewCachedDatabaseWriter(databaseWriter, cache)
|
||||
handler := NewHandler(MakeSqliteSearchFunc(observation.TestContextTB(t), cachedDatabaseWriter, dbmocks.NewMockDB()), func(ctx context.Context, rcp types.RepoCommitPath) ([]byte, error) { return nil, nil }, nil)
|
||||
|
||||
@ -33,7 +33,7 @@ func TestPermsSyncerWorker_Handle(t *testing.T) {
|
||||
syncJobsStore := db.PermissionSyncJobs()
|
||||
|
||||
t.Run("user sync request", func(t *testing.T) {
|
||||
worker := makePermsSyncerWorker(&observation.TestContext, dummySyncer, syncTypeUser, syncJobsStore)
|
||||
worker := makePermsSyncerWorker(observation.TestContextTB(t), dummySyncer, syncTypeUser, syncJobsStore)
|
||||
_ = worker.Handle(ctx, logtest.Scoped(t), &database.PermissionSyncJob{
|
||||
ID: 99,
|
||||
UserID: 1234,
|
||||
@ -55,7 +55,7 @@ func TestPermsSyncerWorker_Handle(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("repo sync request", func(t *testing.T) {
|
||||
worker := makePermsSyncerWorker(&observation.TestContext, dummySyncer, syncTypeRepo, syncJobsStore)
|
||||
worker := makePermsSyncerWorker(observation.TestContextTB(t), dummySyncer, syncTypeRepo, syncJobsStore)
|
||||
_ = worker.Handle(ctx, logtest.Scoped(t), &database.PermissionSyncJob{
|
||||
ID: 777,
|
||||
RepositoryID: 4567,
|
||||
@ -96,7 +96,7 @@ func TestPermsSyncerWorker_RepoSyncJobs(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Creating a worker.
|
||||
observationCtx := &observation.TestContext
|
||||
observationCtx := observation.TestContextTB(t)
|
||||
dummySyncer := &dummySyncerWithErrors{
|
||||
repoIDErrors: map[api.RepoID]errorType{2: allProvidersFailed, 3: realError},
|
||||
}
|
||||
@ -238,7 +238,7 @@ func TestPermsSyncerWorker_UserSyncJobs(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Creating a worker.
|
||||
observationCtx := &observation.TestContext
|
||||
observationCtx := observation.TestContextTB(t)
|
||||
dummySyncer := &dummySyncerWithErrors{
|
||||
userIDErrors: map[int32]errorType{2: allProvidersFailed, 3: realError},
|
||||
userIDNoProviders: map[int32]struct{}{4: {}},
|
||||
@ -423,7 +423,7 @@ func TestPermsSyncerWorker_Store_Dequeue_Order(t *testing.T) {
|
||||
t.Fatalf("unexpected error inserting records: %s", err)
|
||||
}
|
||||
|
||||
store := makeStore(&observation.TestContext, db.Handle(), syncTypeRepo)
|
||||
store := makeStore(observation.TestContextTB(t), db.Handle(), syncTypeRepo)
|
||||
jobIDs := make([]int, 0)
|
||||
wantJobIDs := []int{5, 6, 8, 7, 3, 4, 10, 9, 1, 2, 12, 11, 0, 0, 0, 0}
|
||||
var dequeueErr error
|
||||
|
||||
@ -38,7 +38,7 @@ func TestBatchSpecWorkspaceCreatorProcess(t *testing.T) {
|
||||
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
|
||||
s := store.New(db, &observation.TestContext, nil)
|
||||
s := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
batchSpec, err := btypes.NewBatchSpecFromRaw(bt.TestRawBatchSpecYAML)
|
||||
if err != nil {
|
||||
@ -196,7 +196,7 @@ func TestBatchSpecWorkspaceCreatorProcess_Caching(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
s := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
s := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
creator := &batchSpecWorkspaceCreator{store: s, logger: logtest.Scoped(t)}
|
||||
|
||||
@ -809,7 +809,7 @@ func TestBatchSpecWorkspaceCreatorProcess_Importing(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
s := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
s := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
testSpecYAML := `
|
||||
name: my-unique-name
|
||||
@ -867,7 +867,7 @@ func TestBatchSpecWorkspaceCreatorProcess_NoDiff(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
s := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
s := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
testSpecYAML := `
|
||||
name: my-unique-name
|
||||
@ -925,7 +925,7 @@ func TestBatchSpecWorkspaceCreatorProcess_Secrets(t *testing.T) {
|
||||
|
||||
repos, _ := bt.CreateTestRepos(t, ctx, db, 4)
|
||||
|
||||
s := store.New(db, &observation.TestContext, nil)
|
||||
s := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
secret := &database.ExecutorSecret{
|
||||
Key: "FOO",
|
||||
|
||||
@ -32,7 +32,7 @@ func TestReconcilerWorkerView(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
spec := bt.CreateBatchSpec(t, ctx, bstore, "test-batch-change", user.ID, 0)
|
||||
|
||||
@ -64,7 +64,7 @@ func TestBulkProcessor(t *testing.T) {
|
||||
sqlDB := dbtest.NewDB(t)
|
||||
tx := dbtest.NewTx(t, sqlDB)
|
||||
db := database.NewDB(logger, sqlDB)
|
||||
bstore := store.New(database.NewDBWith(logger, basestore.NewWithHandle(basestore.NewHandleWithTx(tx, sql.TxOptions{}))), &observation.TestContext, nil)
|
||||
bstore := store.New(database.NewDBWith(logger, basestore.NewWithHandle(basestore.NewHandleWithTx(tx, sql.TxOptions{}))), observation.TestContextTB(t), nil)
|
||||
wstore := database.OutboundWebhookJobsWith(bstore, nil)
|
||||
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
|
||||
@ -81,7 +81,7 @@ func TestExecutor_ExecutePlan(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, et.TestKey{}, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), et.TestKey{}, clock)
|
||||
wstore := database.OutboundWebhookJobsWith(bstore, nil)
|
||||
|
||||
admin := bt.CreateTestUser(t, db, true)
|
||||
@ -878,7 +878,7 @@ func TestExecutor_ExecutePlan_PublishedChangesetDuplicateBranch(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, et.TestKey{})
|
||||
bstore := store.New(db, observation.TestContextTB(t), et.TestKey{})
|
||||
|
||||
repo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
|
||||
@ -920,7 +920,7 @@ func TestExecutor_ExecutePlan_AvoidLoadingChangesetSource(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
bstore := store.New(db, &observation.TestContext, et.TestKey{})
|
||||
bstore := store.New(db, observation.TestContextTB(t), et.TestKey{})
|
||||
repo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
|
||||
changesetSpec := bt.BuildChangesetSpec(t, bt.TestSpecOpts{
|
||||
@ -999,7 +999,7 @@ func TestExecutor_UserCredentialsForGitserver(t *testing.T) {
|
||||
ctx := actor.WithInternalActor(context.Background())
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
bstore := store.New(db, &observation.TestContext, et.TestKey{})
|
||||
bstore := store.New(db, observation.TestContextTB(t), et.TestKey{})
|
||||
|
||||
admin := bt.CreateTestUser(t, db, true)
|
||||
user := bt.CreateTestUser(t, db, false)
|
||||
|
||||
@ -31,7 +31,7 @@ func TestReconcilerProcess_IntegrationTest(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
store := bstore.New(db, &observation.TestContext, nil)
|
||||
store := bstore.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
admin := bt.CreateTestUser(t, db, true)
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ func TestServiceApplyBatchChange(t *testing.T) {
|
||||
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
store := bstore.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
store := bstore.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
svc := New(store)
|
||||
|
||||
t.Run("BatchSpec without changesetSpecs", func(t *testing.T) {
|
||||
|
||||
@ -46,7 +46,7 @@ func TestServicePermissionLevels(t *testing.T) {
|
||||
ctx := actor.WithInternalActor(context.Background())
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
s := store.New(db, &observation.TestContext, nil)
|
||||
s := store.New(db, observation.TestContextTB(t), nil)
|
||||
svc := New(s)
|
||||
|
||||
admin := bt.CreateTestUser(t, db, true)
|
||||
@ -306,7 +306,7 @@ func TestService(t *testing.T) {
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
|
||||
s := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
s := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
rs, _ := bt.CreateTestRepos(t, ctx, db, 4)
|
||||
|
||||
fakeSource := &stesting.FakeChangesetSource{}
|
||||
|
||||
@ -59,7 +59,7 @@ func TestService_ResolveWorkspacesForBatchSpec(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
s := store.New(db, &observation.TestContext, nil)
|
||||
s := store.New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
u := bt.CreateTestUser(t, db, false)
|
||||
|
||||
|
||||
@ -151,7 +151,7 @@ func TestStore_CleanBatchSpecExecutionCacheEntries(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
c := &bt.TestClock{Time: timeutil.Now()}
|
||||
s := NewWithClock(db, &observation.TestContext, nil, c.Now)
|
||||
s := NewWithClock(db, observation.TestContextTB(t), nil, c.Now)
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
|
||||
maxSize := 10 * 1024 // 10kb
|
||||
|
||||
@ -159,7 +159,7 @@ func TestBatchSpecResolutionJobs_BatchSpecIDUnique(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
s := NewWithClock(db, &observation.TestContext, nil, c.Now)
|
||||
s := NewWithClock(db, observation.TestContextTB(t), nil, c.Now)
|
||||
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
|
||||
|
||||
@ -710,7 +710,7 @@ func TestStoreGetBatchSpecStats(t *testing.T) {
|
||||
minAgo := func(m int) time.Time { return c.Now().Add(-time.Duration(m) * time.Minute) }
|
||||
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
s := NewWithClock(db, &observation.TestContext, nil, c.Now)
|
||||
s := NewWithClock(db, observation.TestContextTB(t), nil, c.Now)
|
||||
|
||||
repo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
|
||||
@ -885,7 +885,7 @@ func TestStore_ListBatchSpecRepoIDs(t *testing.T) {
|
||||
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
s := New(db, &observation.TestContext, nil)
|
||||
s := New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
// Create two repos, one of which will be visible to everyone, and one which
|
||||
// won't be.
|
||||
|
||||
@ -2373,7 +2373,7 @@ func TestCancelQueuedBatchChangeChangesets(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
s := New(db, &observation.TestContext, nil)
|
||||
s := New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
spec := bt.CreateBatchSpec(t, ctx, s, "test-batch-change", user.ID, 0)
|
||||
@ -2516,7 +2516,7 @@ func TestEnqueueChangesetsToClose(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
s := New(db, &observation.TestContext, nil)
|
||||
s := New(db, observation.TestContextTB(t), nil)
|
||||
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
spec := bt.CreateBatchSpec(t, ctx, s, "test-batch-change", user.ID, 0)
|
||||
@ -2647,7 +2647,7 @@ func TestCleanDetachedChangesets(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
|
||||
s := New(db, &observation.TestContext, nil)
|
||||
s := New(db, observation.TestContextTB(t), nil)
|
||||
rs := database.ReposWith(logger, s)
|
||||
es := database.ExternalServicesWith(logger, s)
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ func storeTest(db *sql.DB, key encryption.Key, f storeTestFunc) func(*testing.T)
|
||||
// don't need to insert a lot of dependencies into the DB (users,
|
||||
// repos, ...) to setup the tests.
|
||||
tx := database.NewDBWith(logger, basestore.NewWithHandle(basestore.NewHandleWithTx(dbtest.NewTx(t, db), sql.TxOptions{})))
|
||||
s := NewWithClock(tx, &observation.TestContext, key, c.Now)
|
||||
s := NewWithClock(tx, observation.TestContextTB(t), key, c.Now)
|
||||
|
||||
f(t, context.Background(), s, c)
|
||||
}
|
||||
|
||||
@ -31,8 +31,8 @@ func TestBatchSpecWorkspaceExecutionWorkerStore_MarkComplete(t *testing.T) {
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
|
||||
repo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
s := New(db, &observation.TestContext, nil)
|
||||
workStore := dbworkerstore.New(&observation.TestContext, s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
s := New(db, observation.TestContextTB(t), nil)
|
||||
workStore := dbworkerstore.New(observation.TestContextTB(t), s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
|
||||
// Setup all the associations
|
||||
batchSpec := &btypes.BatchSpec{UserID: user.ID, NamespaceUserID: user.ID, RawSpec: "horse", Spec: &batcheslib.BatchSpec{
|
||||
@ -69,7 +69,7 @@ stdout: {"operation":"CACHE_AFTER_STEP_RESULT","timestamp":"2021-11-04T12:43:19.
|
||||
|
||||
executionStore := &batchSpecWorkspaceExecutionWorkerStore{
|
||||
Store: workStore,
|
||||
observationCtx: &observation.TestContext,
|
||||
observationCtx: observation.TestContextTB(t),
|
||||
logger: logtest.Scoped(t),
|
||||
}
|
||||
opts := dbworkerstore.MarkFinalOptions{WorkerHostname: "worker-1"}
|
||||
@ -225,8 +225,8 @@ func TestBatchSpecWorkspaceExecutionWorkerStore_MarkFailed(t *testing.T) {
|
||||
user := bt.CreateTestUser(t, db, true)
|
||||
|
||||
repo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
s := New(db, &observation.TestContext, nil)
|
||||
workStore := dbworkerstore.New(&observation.TestContext, s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
s := New(db, observation.TestContextTB(t), nil)
|
||||
workStore := dbworkerstore.New(observation.TestContextTB(t), s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
|
||||
// Setup all the associations
|
||||
batchSpec := &btypes.BatchSpec{UserID: user.ID, NamespaceUserID: user.ID, RawSpec: "horse", Spec: &batcheslib.BatchSpec{
|
||||
@ -278,7 +278,7 @@ stdout: {"operation":"CACHE_AFTER_STEP_RESULT","timestamp":"2021-11-04T12:43:19.
|
||||
|
||||
executionStore := &batchSpecWorkspaceExecutionWorkerStore{
|
||||
Store: workStore,
|
||||
observationCtx: &observation.TestContext,
|
||||
observationCtx: observation.TestContextTB(t),
|
||||
logger: logtest.Scoped(t),
|
||||
}
|
||||
opts := dbworkerstore.MarkFinalOptions{WorkerHostname: "worker-1"}
|
||||
@ -381,8 +381,8 @@ func TestBatchSpecWorkspaceExecutionWorkerStore_MarkComplete_EmptyDiff(t *testin
|
||||
|
||||
repo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
|
||||
s := New(db, &observation.TestContext, nil)
|
||||
workStore := dbworkerstore.New(&observation.TestContext, s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
s := New(db, observation.TestContextTB(t), nil)
|
||||
workStore := dbworkerstore.New(observation.TestContextTB(t), s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
|
||||
// Setup all the associations
|
||||
batchSpec := &btypes.BatchSpec{UserID: user.ID, NamespaceUserID: user.ID, RawSpec: "horse", Spec: &batcheslib.BatchSpec{
|
||||
@ -423,7 +423,7 @@ stdout: {"operation":"CACHE_AFTER_STEP_RESULT","timestamp":"2021-11-04T12:43:19.
|
||||
|
||||
executionStore := &batchSpecWorkspaceExecutionWorkerStore{
|
||||
Store: workStore,
|
||||
observationCtx: &observation.TestContext,
|
||||
observationCtx: observation.TestContextTB(t),
|
||||
}
|
||||
opts := dbworkerstore.MarkFinalOptions{WorkerHostname: "worker-1"}
|
||||
|
||||
@ -465,8 +465,8 @@ func TestBatchSpecWorkspaceExecutionWorkerStore_Dequeue_RoundRobin(t *testing.T)
|
||||
|
||||
repo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
|
||||
s := New(db, &observation.TestContext, nil)
|
||||
workerStore := dbworkerstore.New(&observation.TestContext, s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
s := New(db, observation.TestContextTB(t), nil)
|
||||
workerStore := dbworkerstore.New(observation.TestContextTB(t), s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
|
||||
user1 := bt.CreateTestUser(t, db, true)
|
||||
user2 := bt.CreateTestUser(t, db, true)
|
||||
@ -514,8 +514,8 @@ func TestBatchSpecWorkspaceExecutionWorkerStore_Dequeue_RoundRobin_NoDoubleDeque
|
||||
|
||||
repo, _ := bt.CreateTestRepo(t, ctx, db)
|
||||
|
||||
s := New(db, &observation.TestContext, nil)
|
||||
workerStore := dbworkerstore.New(&observation.TestContext, s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
s := New(db, observation.TestContextTB(t), nil)
|
||||
workerStore := dbworkerstore.New(observation.TestContextTB(t), s.Handle(), batchSpecWorkspaceExecutionWorkerStoreOptions)
|
||||
|
||||
user1 := bt.CreateTestUser(t, db, true)
|
||||
user2 := bt.CreateTestUser(t, db, true)
|
||||
|
||||
@ -60,7 +60,7 @@ func TestSyncerRun(t *testing.T) {
|
||||
syncStore: syncStore,
|
||||
scheduleInterval: 10 * time.Minute,
|
||||
syncFunc: syncFunc,
|
||||
metrics: makeMetrics(&observation.TestContext),
|
||||
metrics: makeMetrics(observation.TestContextTB(t)),
|
||||
}
|
||||
go syncer.Run(ctx)
|
||||
select {
|
||||
@ -100,7 +100,7 @@ func TestSyncerRun(t *testing.T) {
|
||||
logger: logtest.Scoped(t),
|
||||
syncStore: syncStore,
|
||||
scheduleInterval: 10 * time.Minute,
|
||||
metrics: makeMetrics(&observation.TestContext),
|
||||
metrics: makeMetrics(observation.TestContextTB(t)),
|
||||
}
|
||||
syncer.Run(ctx)
|
||||
if updateCalled {
|
||||
@ -132,7 +132,7 @@ func TestSyncerRun(t *testing.T) {
|
||||
syncStore: syncStore,
|
||||
scheduleInterval: 10 * time.Minute,
|
||||
syncFunc: syncFunc,
|
||||
metrics: makeMetrics(&observation.TestContext),
|
||||
metrics: makeMetrics(observation.TestContextTB(t)),
|
||||
}
|
||||
syncer.Run(ctx)
|
||||
if syncCalled {
|
||||
@ -154,7 +154,7 @@ func TestSyncerRun(t *testing.T) {
|
||||
scheduleInterval: 10 * time.Minute,
|
||||
syncFunc: syncFunc,
|
||||
priorityNotify: make(chan []int64, 1),
|
||||
metrics: makeMetrics(&observation.TestContext),
|
||||
metrics: makeMetrics(observation.TestContextTB(t)),
|
||||
}
|
||||
syncer.priorityNotify <- []int64{1}
|
||||
go syncer.Run(ctx)
|
||||
@ -211,7 +211,7 @@ func TestSyncerRun(t *testing.T) {
|
||||
logger: capturingLogger,
|
||||
syncStore: syncStore,
|
||||
scheduleInterval: 10 * time.Minute,
|
||||
metrics: makeMetrics(&observation.TestContext),
|
||||
metrics: makeMetrics(observation.TestContextTB(t)),
|
||||
}
|
||||
syncer.Run(ctx)
|
||||
assert.False(t, updateCalled)
|
||||
@ -251,7 +251,7 @@ func TestSyncRegistry_SyncCodeHosts(t *testing.T) {
|
||||
return codeHosts, nil
|
||||
})
|
||||
|
||||
reg := NewSyncRegistry(ctx, &observation.TestContext, syncStore, nil)
|
||||
reg := NewSyncRegistry(ctx, observation.TestContextTB(t), syncStore, nil)
|
||||
|
||||
assertSyncerCount := func(t *testing.T, want int) {
|
||||
t.Helper()
|
||||
@ -309,12 +309,12 @@ func TestSyncRegistry_EnqueueChangesetSyncs(t *testing.T) {
|
||||
return nil
|
||||
},
|
||||
priorityNotify: make(chan []int64, 1),
|
||||
metrics: makeMetrics(&observation.TestContext),
|
||||
metrics: makeMetrics(observation.TestContextTB(t)),
|
||||
cancel: syncerCancel,
|
||||
}
|
||||
go syncer.Run(syncerCtx)
|
||||
|
||||
reg := NewSyncRegistry(ctx, &observation.TestContext, syncStore, nil)
|
||||
reg := NewSyncRegistry(ctx, observation.TestContextTB(t), syncStore, nil)
|
||||
reg.syncers[codeHostURL] = syncer
|
||||
|
||||
// Start handler in background, will be canceled when ctx is canceled
|
||||
|
||||
@ -33,7 +33,7 @@ func TestMarshalBatchChange(t *testing.T) {
|
||||
marshalledUserID := gql.MarshalUserID(userID)
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
batchSpec := bt.CreateBatchSpec(t, ctx, bstore, "test", userID, 0)
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ func TestMarshalChangeset(t *testing.T) {
|
||||
userID := bt.CreateTestUser(t, db, true).ID
|
||||
now := timeutil.Now()
|
||||
clock := func() time.Time { return now }
|
||||
bstore := store.NewWithClock(db, &observation.TestContext, nil, clock)
|
||||
bstore := store.NewWithClock(db, observation.TestContextTB(t), nil, clock)
|
||||
|
||||
batchSpec := bt.CreateBatchSpec(t, ctx, bstore, "test", userID, 0)
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ func Test_AutoIndexingManualEnqueuedDequeueOrder(t *testing.T) {
|
||||
db := database.NewDB(logtest.Scoped(t), raw)
|
||||
|
||||
opts := IndexWorkerStoreOptions
|
||||
workerstore := store.New(&observation.TestContext, db.Handle(), opts)
|
||||
workerstore := store.New(observation.TestContextTB(t), db.Handle(), opts)
|
||||
|
||||
for i, test := range []struct {
|
||||
indexes []shared.Index
|
||||
|
||||
@ -54,5 +54,5 @@ func testService(t *testing.T, repositoryContents map[string]string) *Service {
|
||||
return unpacktest.CreateTarArchive(t, files), nil
|
||||
})
|
||||
|
||||
return newService(&observation.TestContext, sandboxService, gitService, ratelimit.NewInstrumentedLimiter("TestInference", rate.NewLimiter(rate.Limit(100), 1)), 100, 1024*1024)
|
||||
return newService(observation.TestContextTB(t), sandboxService, gitService, ratelimit.NewInstrumentedLimiter("TestInference", rate.NewLimiter(rate.Limit(100), 1)), 100, 1024*1024)
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import (
|
||||
func TestSetInferenceScript(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
for _, testCase := range []struct {
|
||||
script string
|
||||
|
||||
@ -16,7 +16,7 @@ import (
|
||||
func TestRepositoryExceptions(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
query := sqlf.Sprintf(
|
||||
`INSERT INTO repo (id, name) VALUES (%s, %s)`,
|
||||
@ -56,7 +56,7 @@ func TestRepositoryExceptions(t *testing.T) {
|
||||
func TestGetIndexConfigurationByRepositoryID(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
expectedConfigurationData := []byte(`{
|
||||
"foo": "bar",
|
||||
@ -98,7 +98,7 @@ func TestGetIndexConfigurationByRepositoryID(t *testing.T) {
|
||||
func TestUpdateIndexConfigurationByRepositoryID(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
query := sqlf.Sprintf(
|
||||
`INSERT INTO repo (id, name) VALUES (%s, %s)`,
|
||||
|
||||
@ -22,7 +22,7 @@ func TestTopRepositoriesToConfigure(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
sqlDB := dbtest.NewDB(t)
|
||||
db := database.NewDB(logger, sqlDB)
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
insertEvent := func(name string, repositoryID int, maxAge time.Duration) {
|
||||
query := `
|
||||
@ -73,7 +73,7 @@ func TestRepositoryIDsWithConfiguration(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
sqlDB := dbtest.NewDB(t)
|
||||
db := database.NewDB(logger, sqlDB)
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
testIndexerList := map[string]uploadsshared.AvailableIndexer{
|
||||
"test-indexer": {
|
||||
@ -119,7 +119,7 @@ func TestGetLastIndexScanForRepository(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
ts, err := store.GetLastIndexScanForRepository(ctx, 50)
|
||||
if err != nil {
|
||||
|
||||
@ -16,7 +16,7 @@ import (
|
||||
func TestInsertDependencyIndexingJob(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
insertRepo(t, db, 50, "")
|
||||
|
||||
@ -46,7 +46,7 @@ func TestGetQueuedRepoRev(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
expected := []RepoRev{
|
||||
{1, 50, "HEAD"},
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
func TestIsQueued(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
insertIndexes(t, db, uploadsshared.Index{ID: 1, RepositoryID: 1, Commit: makeCommit(1)})
|
||||
insertIndexes(t, db, uploadsshared.Index{ID: 2, RepositoryID: 1, Commit: makeCommit(1), ShouldReindex: true})
|
||||
@ -64,7 +64,7 @@ func TestIsQueued(t *testing.T) {
|
||||
func TestIsQueuedRootIndexer(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
now := time.Now()
|
||||
insertIndexes(t, db, uploadsshared.Index{ID: 1, RepositoryID: 1, Commit: makeCommit(1), Root: "/foo", Indexer: "i1", QueuedAt: now.Add(-time.Hour * 1)})
|
||||
@ -106,7 +106,7 @@ func TestInsertIndexes(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
insertRepo(t, db, 50, "")
|
||||
|
||||
@ -231,7 +231,7 @@ func TestInsertIndexes(t *testing.T) {
|
||||
func TestInsertIndexWithActor(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
insertRepo(t, db, 50, "")
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ func TestMarkRepoRevsAsProcessed(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
expected := []RepoRev{
|
||||
{1, 50, "HEAD"},
|
||||
@ -65,7 +65,7 @@ func testStoreWithoutConfigurationPolicies(t *testing.T, db database.DB) Store {
|
||||
t.Fatalf("unexpected error while inserting configuration policies: %s", err)
|
||||
}
|
||||
|
||||
return New(&observation.TestContext, db)
|
||||
return New(observation.TestContextTB(t), db)
|
||||
}
|
||||
|
||||
func updateGitserverUpdatedAt(t *testing.T, db database.DB, now time.Time) {
|
||||
|
||||
@ -64,7 +64,7 @@ func TestQueueIndexesExplicit(t *testing.T) {
|
||||
inferenceService := NewMockInferenceService()
|
||||
|
||||
service := newService(
|
||||
&observation.TestContext,
|
||||
observation.TestContextTB(t),
|
||||
mockDBStore,
|
||||
inferenceService,
|
||||
defaultMockRepoStore(), // repoStore
|
||||
@ -162,7 +162,7 @@ func TestQueueIndexesInDatabase(t *testing.T) {
|
||||
inferenceService := NewMockInferenceService()
|
||||
|
||||
service := newService(
|
||||
&observation.TestContext,
|
||||
observation.TestContextTB(t),
|
||||
mockDBStore,
|
||||
inferenceService,
|
||||
defaultMockRepoStore(), // repoStore
|
||||
@ -265,7 +265,7 @@ func TestQueueIndexesInRepository(t *testing.T) {
|
||||
inferenceService := NewMockInferenceService()
|
||||
|
||||
service := newService(
|
||||
&observation.TestContext,
|
||||
observation.TestContextTB(t),
|
||||
mockDBStore,
|
||||
inferenceService,
|
||||
defaultMockRepoStore(), // repoStore
|
||||
@ -351,7 +351,7 @@ func TestQueueIndexesInferred(t *testing.T) {
|
||||
})
|
||||
|
||||
service := newService(
|
||||
&observation.TestContext,
|
||||
observation.TestContextTB(t),
|
||||
mockDBStore,
|
||||
inferenceService,
|
||||
defaultMockRepoStore(), // repoStore
|
||||
@ -439,7 +439,7 @@ func TestQueueIndexesForPackage(t *testing.T) {
|
||||
})
|
||||
|
||||
service := newService(
|
||||
&observation.TestContext,
|
||||
observation.TestContextTB(t),
|
||||
mockDBStore,
|
||||
inferenceService,
|
||||
mockRepoStore, // repoStore
|
||||
|
||||
@ -316,7 +316,7 @@ func TestDatabaseReferences(t *testing.T) {
|
||||
func populateTestStore(t testing.TB) LsifStore {
|
||||
logger := logtest.Scoped(t)
|
||||
codeIntelDB := codeintelshared.NewCodeIntelDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, codeIntelDB)
|
||||
store := New(observation.TestContextTB(t), codeIntelDB)
|
||||
|
||||
loadTestFile(t, codeIntelDB, "./testdata/code-intel-extensions@7802976b.sql")
|
||||
return store
|
||||
|
||||
@ -25,7 +25,7 @@ func TestDiagnostics(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
@ -98,7 +98,7 @@ func TestDiagnosticsWithSubRepoPermissions(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
|
||||
@ -25,7 +25,7 @@ func TestHover(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
@ -81,7 +81,7 @@ func TestHoverRemote(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
|
||||
@ -26,7 +26,7 @@ func TestGetDefinitions(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
@ -86,7 +86,7 @@ func TestGetDefinitions(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
@ -208,7 +208,7 @@ func TestGetReferences(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
@ -273,7 +273,7 @@ func TestGetReferences(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
@ -454,7 +454,7 @@ func TestGetImplementations(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
|
||||
@ -51,7 +51,7 @@ func TestRanges(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
|
||||
@ -26,7 +26,7 @@ func TestSnapshotForDocument(t *testing.T) {
|
||||
mockGitserverClient := gitserver.NewMockClient()
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
mockUploadSvc.GetCompletedUploadsByIDsFunc.SetDefaultReturn([]shared.CompletedUpload{{}}, nil)
|
||||
mockRepoStore.GetFunc.SetDefaultReturn(&types.Repo{}, nil)
|
||||
|
||||
@ -22,7 +22,7 @@ func TestStencil(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
@ -80,7 +80,7 @@ func TestStencilWithDuplicateRanges(t *testing.T) {
|
||||
hunkCache, _ := NewHunkCache(50)
|
||||
|
||||
// Init service
|
||||
svc := newService(&observation.TestContext, mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockRepoStore, mockLsifStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
// Set up request state
|
||||
mockRequestState := RequestState{}
|
||||
|
||||
@ -29,7 +29,7 @@ func TestRanges(t *testing.T) {
|
||||
Commit: "deadbeef1",
|
||||
Path: "/src/main",
|
||||
}
|
||||
mockOperations := newOperations(&observation.TestContext)
|
||||
mockOperations := newOperations(observation.TestContextTB(t))
|
||||
|
||||
resolver := newGitBlobLSIFDataResolver(
|
||||
mockCodeNavService,
|
||||
@ -64,7 +64,7 @@ func TestDefinitions(t *testing.T) {
|
||||
Commit: "deadbeef1",
|
||||
Path: "/src/main",
|
||||
}
|
||||
mockOperations := newOperations(&observation.TestContext)
|
||||
mockOperations := newOperations(observation.TestContextTB(t))
|
||||
|
||||
resolver := newGitBlobLSIFDataResolver(
|
||||
mockCodeNavService,
|
||||
@ -99,7 +99,7 @@ func TestReferences(t *testing.T) {
|
||||
Commit: "deadbeef1",
|
||||
Path: "/src/main",
|
||||
}
|
||||
mockOperations := newOperations(&observation.TestContext)
|
||||
mockOperations := newOperations(observation.TestContextTB(t))
|
||||
|
||||
resolver := newGitBlobLSIFDataResolver(
|
||||
mockCodeNavService,
|
||||
@ -152,7 +152,7 @@ func TestReferencesDefaultLimit(t *testing.T) {
|
||||
Commit: "deadbeef1",
|
||||
Path: "/src/main",
|
||||
}
|
||||
mockOperations := newOperations(&observation.TestContext)
|
||||
mockOperations := newOperations(observation.TestContextTB(t))
|
||||
|
||||
resolver := newGitBlobLSIFDataResolver(
|
||||
mockCodeNavService,
|
||||
@ -191,7 +191,7 @@ func TestReferencesDefaultIllegalLimit(t *testing.T) {
|
||||
Commit: "deadbeef1",
|
||||
Path: "/src/main",
|
||||
}
|
||||
mockOperations := newOperations(&observation.TestContext)
|
||||
mockOperations := newOperations(observation.TestContextTB(t))
|
||||
|
||||
resolver := newGitBlobLSIFDataResolver(
|
||||
mockCodeNavService,
|
||||
@ -224,7 +224,7 @@ func TestHover(t *testing.T) {
|
||||
Commit: "deadbeef1",
|
||||
Path: "/src/main",
|
||||
}
|
||||
mockOperations := newOperations(&observation.TestContext)
|
||||
mockOperations := newOperations(observation.TestContextTB(t))
|
||||
|
||||
resolver := newGitBlobLSIFDataResolver(
|
||||
mockCodeNavService,
|
||||
@ -260,7 +260,7 @@ func TestDiagnostics(t *testing.T) {
|
||||
Commit: "deadbeef1",
|
||||
Path: "/src/main",
|
||||
}
|
||||
mockOperations := newOperations(&observation.TestContext)
|
||||
mockOperations := newOperations(observation.TestContextTB(t))
|
||||
|
||||
resolver := newGitBlobLSIFDataResolver(
|
||||
mockCodeNavService,
|
||||
@ -296,7 +296,7 @@ func TestDiagnosticsDefaultLimit(t *testing.T) {
|
||||
Commit: "deadbeef1",
|
||||
Path: "/src/main",
|
||||
}
|
||||
mockOperations := newOperations(&observation.TestContext)
|
||||
mockOperations := newOperations(observation.TestContextTB(t))
|
||||
|
||||
resolver := newGitBlobLSIFDataResolver(
|
||||
mockCodeNavService,
|
||||
@ -329,7 +329,7 @@ func TestDiagnosticsDefaultIllegalLimit(t *testing.T) {
|
||||
Commit: "deadbeef1",
|
||||
Path: "/src/main",
|
||||
}
|
||||
mockOperations := newOperations(&observation.TestContext)
|
||||
mockOperations := newOperations(observation.TestContextTB(t))
|
||||
|
||||
resolver := newGitBlobLSIFDataResolver(
|
||||
mockCodeNavService,
|
||||
|
||||
@ -22,7 +22,7 @@ func TestPackageRepoFiltersBlockOnly(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
s := store.New(&observation.TestContext, db)
|
||||
s := store.New(observation.TestContextTB(t), db)
|
||||
|
||||
deps := []shared.MinimalPackageRepoRef{
|
||||
{Scheme: "npm", Name: "bar", Versions: []shared.MinimalPackageRepoRefVersion{{Version: "2.0.0"}, {Version: "2.0.1"}, {Version: "3.0.0"}}},
|
||||
@ -63,7 +63,7 @@ func TestPackageRepoFiltersBlockOnly(t *testing.T) {
|
||||
job := packagesFilterApplicatorJob{
|
||||
store: s,
|
||||
extsvcStore: db.ExternalServices(),
|
||||
operations: newOperations(&observation.TestContext),
|
||||
operations: newOperations(observation.TestContextTB(t)),
|
||||
}
|
||||
|
||||
if err := job.handle(ctx); err != nil {
|
||||
@ -114,7 +114,7 @@ func TestPackageRepoFiltersBlockAllow(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
s := store.New(&observation.TestContext, db)
|
||||
s := store.New(observation.TestContextTB(t), db)
|
||||
|
||||
deps := []shared.MinimalPackageRepoRef{
|
||||
{Scheme: "npm", Name: "bar", Versions: []shared.MinimalPackageRepoRefVersion{{Version: "2.0.0"}, {Version: "2.0.1"}, {Version: "3.0.0"}}},
|
||||
@ -168,7 +168,7 @@ func TestPackageRepoFiltersBlockAllow(t *testing.T) {
|
||||
job := packagesFilterApplicatorJob{
|
||||
store: s,
|
||||
extsvcStore: db.ExternalServices(),
|
||||
operations: newOperations(&observation.TestContext),
|
||||
operations: newOperations(observation.TestContextTB(t)),
|
||||
}
|
||||
|
||||
if err := job.handle(ctx); err != nil {
|
||||
|
||||
@ -22,7 +22,7 @@ func TestInsertDependencyRepo(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
batches := [][]shared.MinimalPackageRepoRef{
|
||||
{
|
||||
@ -103,7 +103,7 @@ func TestListPackageRepoRefs(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
batches := [][]shared.MinimalPackageRepoRef{
|
||||
{
|
||||
@ -193,7 +193,7 @@ func TestListPackageRepoRefsFuzzy(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
pkgs := []shared.MinimalPackageRepoRef{
|
||||
{Scheme: "npm", Name: "bar", Versions: []shared.MinimalPackageRepoRefVersion{{Version: "2.0.0"}}},
|
||||
@ -317,7 +317,7 @@ func TestDeletePackageRepoRefsByID(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
repos := []shared.MinimalPackageRepoRef{
|
||||
// Test same-set flushes
|
||||
|
||||
@ -21,7 +21,7 @@ func TestRepoIDsByGlobPatterns(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
insertRepo(t, db, 50, "Darth Vader", true)
|
||||
insertRepo(t, db, 51, "Darth Venamis", true)
|
||||
@ -99,7 +99,7 @@ func TestUpdateReposMatchingPatterns(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
insertRepo(t, db, 50, "r1", false)
|
||||
insertRepo(t, db, 51, "r2", false)
|
||||
@ -166,7 +166,7 @@ func TestUpdateReposMatchingPatternsOverLimit(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
limit := 50
|
||||
ids := make([]int, 0, limit*3)
|
||||
|
||||
@ -21,7 +21,7 @@ func testStoreWithoutConfigurationPolicies(t *testing.T, db database.DB) Store {
|
||||
t.Fatalf("unexpected error while inserting configuration policies: %s", err)
|
||||
}
|
||||
|
||||
return New(&observation.TestContext, db)
|
||||
return New(observation.TestContextTB(t), db)
|
||||
}
|
||||
|
||||
// insertRepo creates a repository record with the given id and name. If there is already a repository
|
||||
|
||||
@ -26,7 +26,7 @@ func TestGetRetentionPolicyOverview(t *testing.T) {
|
||||
mockUploadSvc := NewMockUploadService()
|
||||
mockGitserverClient := gitserver.NewMockClient()
|
||||
|
||||
svc := newService(&observation.TestContext, mockStore, mockRepoStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockStore, mockRepoStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
mockClock := glock.NewMockClock()
|
||||
|
||||
@ -226,7 +226,7 @@ func TestRetentionPolicyOverview_ByVisibility(t *testing.T) {
|
||||
mockUploadSvc := NewMockUploadService()
|
||||
mockGitserverClient := gitserver.NewMockClient()
|
||||
|
||||
svc := newService(&observation.TestContext, mockStore, mockRepoStore, mockUploadSvc, mockGitserverClient)
|
||||
svc := newService(observation.TestContextTB(t), mockStore, mockRepoStore, mockUploadSvc, mockGitserverClient)
|
||||
|
||||
mockClock := glock.NewMockClock()
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ func TestCoordinateAndSummaries(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := dbtest.NewDB(t)
|
||||
store := New(&observation.TestContext, database.NewDB(logger, db))
|
||||
store := New(observation.TestContextTB(t), database.NewDB(logger, db))
|
||||
|
||||
now1 := timeutil.Now().UTC()
|
||||
now2 := now1.Add(time.Hour * 2)
|
||||
|
||||
@ -20,7 +20,7 @@ func TestInsertDefinition(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
// Insert uploads
|
||||
insertUploads(t, db, uploadsshared.Upload{ID: 4})
|
||||
|
||||
@ -15,7 +15,7 @@ func TestDerivativeGraphKey(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
if _, _, err := DerivativeGraphKey(ctx, store); err != nil {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
|
||||
@ -25,7 +25,7 @@ func TestInsertPathCountInputs(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
key := rankingshared.NewDerivativeGraphKey(mockRankingGraphKey, "123")
|
||||
|
||||
@ -198,7 +198,7 @@ func TestInsertInitialPathCounts(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
key := rankingshared.NewDerivativeGraphKey(mockRankingGraphKey, "123")
|
||||
|
||||
@ -256,7 +256,7 @@ func TestVacuumStaleProcessedReferences(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
key := rankingshared.NewDerivativeGraphKey(mockRankingGraphKey, "123")
|
||||
|
||||
@ -320,7 +320,7 @@ func TestVacuumStaleProcessedPaths(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
key := rankingshared.NewDerivativeGraphKey(mockRankingGraphKey, "123")
|
||||
|
||||
@ -384,7 +384,7 @@ func TestVacuumStaleGraphs(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
key := rankingshared.NewDerivativeGraphKey(mockRankingGraphKey, "123")
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ func TestInsertInitialPathRanks(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
// Insert uploads
|
||||
insertUploads(t, db, uploadsshared.Upload{ID: 4})
|
||||
|
||||
@ -27,7 +27,7 @@ func TestInsertPathRanks(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
key := rankingshared.NewDerivativeGraphKey(mockRankingGraphKey, "123")
|
||||
|
||||
@ -137,7 +137,7 @@ func TestVacuumStaleRanks(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
if _, err := db.ExecContext(ctx, `
|
||||
INSERT INTO repo (name) VALUES ('bar'), ('baz'), ('bonk'), ('foo1'), ('foo2'), ('foo3'), ('foo4'), ('foo5')`); err != nil {
|
||||
|
||||
@ -21,7 +21,7 @@ func TestInsertReferences(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
// Insert uploads
|
||||
insertUploads(t, db, uploadsshared.Upload{ID: 4})
|
||||
|
||||
@ -26,7 +26,7 @@ func TestGetStarRank(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
if _, err := db.ExecContext(ctx, `
|
||||
INSERT INTO repo (name, stars)
|
||||
@ -73,7 +73,7 @@ func TestDocumentRanks(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
repoName := api.RepoName("foo")
|
||||
|
||||
key := rankingshared.NewDerivativeGraphKey(mockRankingGraphKey, "123")
|
||||
@ -130,7 +130,7 @@ func TestGetReferenceCountStatistics(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
key := rankingshared.NewDerivativeGraphKey(mockRankingGraphKey, "123")
|
||||
|
||||
@ -175,7 +175,7 @@ func TestCoverageCounts(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
// Create three visible uploads and export a pair
|
||||
if _, err := db.ExecContext(ctx, `
|
||||
@ -239,7 +239,7 @@ func TestLastUpdatedAt(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
now := time.Unix(1686695462, 0)
|
||||
key := rankingshared.NewDerivativeGraphKey(mockRankingGraphKey, "123")
|
||||
|
||||
@ -24,7 +24,7 @@ func TestGetUploadsForRanking(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
if _, err := db.ExecContext(ctx, `
|
||||
INSERT INTO repo (id, name, deleted_at) VALUES (50, 'foo', NULL);
|
||||
@ -74,7 +74,7 @@ func TestVacuumAbandonedExportedUploads(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
// Insert uploads
|
||||
for i := 1; i <= 9; i++ {
|
||||
@ -127,7 +127,7 @@ func TestSoftDeleteStaleExportedUploads(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
// Insert uploads
|
||||
for i := 1; i <= 9; i++ {
|
||||
@ -186,7 +186,7 @@ func TestVacuumDeletedExportedUploads(t *testing.T) {
|
||||
logger := logtest.Scoped(t)
|
||||
ctx := context.Background()
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
// Insert uploads
|
||||
for i := 1; i <= 9; i++ {
|
||||
|
||||
@ -13,7 +13,7 @@ import (
|
||||
func TestGetRepoRank(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
mockStore := NewMockStore()
|
||||
svc := newService(&observation.TestContext, mockStore, nil, conf.DefaultClient())
|
||||
svc := newService(observation.TestContextTB(t), mockStore, nil, conf.DefaultClient())
|
||||
|
||||
mockStore.GetStarRankFunc.SetDefaultReturn(0.6, nil)
|
||||
|
||||
@ -34,7 +34,7 @@ func TestGetRepoRankWithUserBoostedScores(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
mockStore := NewMockStore()
|
||||
mockConfigQuerier := NewMockSiteConfigQuerier()
|
||||
svc := newService(&observation.TestContext, mockStore, nil, mockConfigQuerier)
|
||||
svc := newService(observation.TestContextTB(t), mockStore, nil, mockConfigQuerier)
|
||||
|
||||
mockStore.GetStarRankFunc.SetDefaultReturn(0.6, nil)
|
||||
mockConfigQuerier.SiteConfigFunc.SetDefaultReturn(schema.SiteConfiguration{
|
||||
|
||||
@ -237,7 +237,7 @@ func testPreciseStoreWithoutConfigurationPolicies(t *testing.T, db database.DB)
|
||||
t.Fatalf("unexpected error while inserting configuration policies: %s", err)
|
||||
}
|
||||
|
||||
return NewPreciseStore(&observation.TestContext, db)
|
||||
return NewPreciseStore(observation.TestContextTB(t), db)
|
||||
}
|
||||
|
||||
func testSyntacticStoreWithoutConfigurationPolicies(t *testing.T, db database.DB) RepositorySchedulingStore {
|
||||
@ -245,7 +245,7 @@ func testSyntacticStoreWithoutConfigurationPolicies(t *testing.T, db database.DB
|
||||
t.Fatalf("unexpected error while inserting configuration policies: %s", err)
|
||||
}
|
||||
|
||||
return NewSyntacticStore(&observation.TestContext, db)
|
||||
return NewSyntacticStore(observation.TestContextTB(t), db)
|
||||
}
|
||||
|
||||
func assertRepoList(t *testing.T, store RepositorySchedulingStore, batchOptions RepositoryBatchOptions, now time.Time, want []int) {
|
||||
|
||||
@ -24,7 +24,7 @@ func TestVulnerabilityMatchByID(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
setupReferences(t, db)
|
||||
|
||||
@ -59,7 +59,7 @@ func TestGetVulnerabilityMatches(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
/*
|
||||
* Setup references is inserting seven (7) total references.
|
||||
@ -200,7 +200,7 @@ func TestGetVulberabilityMatchesCountByRepository(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
/*
|
||||
* Setup references is inserting seven (7) total references.
|
||||
@ -272,7 +272,7 @@ func TestGetVulnerabilityMatchesSummaryCount(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
handle := basestore.NewWithHandle(db.Handle())
|
||||
|
||||
/* Insert uploads for four (4) repositories */
|
||||
|
||||
@ -37,7 +37,7 @@ func TestVulnerabilityByID(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
if _, err := store.InsertVulnerabilities(ctx, testVulnerabilities); err != nil {
|
||||
t.Fatalf("unexpected error inserting vulnerabilities: %s", err)
|
||||
@ -59,7 +59,7 @@ func TestGetVulnerabilitiesByIDs(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
if _, err := store.InsertVulnerabilities(ctx, testVulnerabilities); err != nil {
|
||||
t.Fatalf("unexpected error inserting vulnerabilities: %s", err)
|
||||
@ -78,7 +78,7 @@ func TestGetVulnerabilities(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
logger := logtest.Scoped(t)
|
||||
db := database.NewDB(logger, dbtest.NewDB(t))
|
||||
store := New(&observation.TestContext, db)
|
||||
store := New(observation.TestContextTB(t), db)
|
||||
|
||||
if _, err := store.InsertVulnerabilities(ctx, testVulnerabilities); err != nil {
|
||||
t.Fatalf("unexpected error inserting vulnerabilities: %s", err)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user