Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Jun 26, 2024
1 parent 52fe297 commit b9390cf
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions pkg/oonimkall/taskrunner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestTaskRunnerRun(t *testing.T) {
//
// You MAY override some functions to provoke specific errors
// or generally change the operating conditions.
fakeSuccessfulRun := func() *MockableTaskRunnerDependencies {
fakeSuccessfulDeps := func() *MockableTaskRunnerDependencies {
deps := &MockableTaskRunnerDependencies{

// Configure the fake experiment
Expand Down Expand Up @@ -307,7 +307,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with invalid experiment name", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Session.MockNewExperimentBuilder = func(name string) (model.ExperimentBuilder, error) {
return nil, errors.New("invalid experiment name")
}
Expand All @@ -325,7 +325,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with error during backends lookup", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Session.MockMaybeLookupBackendsContext = func(ctx context.Context) error {
return errors.New("mocked error")
}
Expand All @@ -343,7 +343,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with error during location lookup", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Session.MockMaybeLookupLocationContext = func(ctx context.Context) error {
return errors.New("mocked error")
}
Expand All @@ -365,7 +365,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with error during target loading", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputOrQueryBackend
}
Expand All @@ -386,7 +386,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with missing input and InputStrictlyRequired policy", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputStrictlyRequired
}
Expand All @@ -409,7 +409,7 @@ func TestTaskRunnerRun(t *testing.T) {
func(t *testing.T) {
runner, emitter := newRunnerForTesting()
runner.settings.Name = "Antani" // no input for this experiment
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputOrStaticDefault
}
Expand All @@ -431,7 +431,7 @@ func TestTaskRunnerRun(t *testing.T) {
t.Run("with InputNone policy and provided input", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
runner.settings.Inputs = append(runner.settings.Inputs, "https://x.org/")
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputNone
}
Expand All @@ -452,7 +452,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with failure opening report", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Experiment.MockOpenReportContext = func(ctx context.Context) error {
return errors.New("mocked error")
}
Expand All @@ -473,7 +473,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with success and just a single entry", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputNone
}
Expand All @@ -499,7 +499,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with failure and just a single entry", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputNone
}
Expand Down Expand Up @@ -529,7 +529,7 @@ func TestTaskRunnerRun(t *testing.T) {
// we are not crashing when the measurement fails and there are annotations,
// which is what was happening in the above referenced issue.
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputNone
}
Expand Down Expand Up @@ -560,7 +560,7 @@ func TestTaskRunnerRun(t *testing.T) {
t.Run("with success and explicit input provided", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
runner.settings.Inputs = []string{"a", "b", "c", "d"}
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputStrictlyRequired
}
Expand Down Expand Up @@ -608,7 +608,7 @@ func TestTaskRunnerRun(t *testing.T) {
t.Run("with success and InputOptional and input", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
runner.settings.Inputs = []string{"a", "b", "c", "d"}
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputOptional
}
Expand Down Expand Up @@ -655,7 +655,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with success and InputOptional and no input", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputOptional
}
Expand Down Expand Up @@ -685,7 +685,7 @@ func TestTaskRunnerRun(t *testing.T) {
experimentName := "DNSCheck"
runner, emitter := newRunnerForTesting()
runner.settings.Name = experimentName
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputOrStaticDefault
}
Expand Down Expand Up @@ -721,7 +721,7 @@ func TestTaskRunnerRun(t *testing.T) {
runner, emitter := newRunnerForTesting()
runner.settings.Inputs = []string{"a", "b", "c", "d"}
runner.settings.Options.MaxRuntime = 2
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputStrictlyRequired
}
Expand Down Expand Up @@ -762,7 +762,7 @@ func TestTaskRunnerRun(t *testing.T) {
runner, emitter := newRunnerForTesting()
runner.settings.Inputs = []string{"a", "b", "c", "d"}
runner.settings.Options.MaxRuntime = 2
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputStrictlyRequired
}
Expand Down Expand Up @@ -804,7 +804,7 @@ func TestTaskRunnerRun(t *testing.T) {
t.Run("with measurement submission failure", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
runner.settings.Inputs = []string{"a"}
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
fake.Builder.MockInputPolicy = func() model.InputPolicy {
return model.InputStrictlyRequired
}
Expand Down Expand Up @@ -843,7 +843,7 @@ func TestTaskRunnerRun(t *testing.T) {

t.Run("with success and progress", func(t *testing.T) {
runner, emitter := newRunnerForTesting()
fake := fakeSuccessfulRun()
fake := fakeSuccessfulDeps()
var callbacks model.ExperimentCallbacks
fake.Builder.MockSetCallbacks = func(cbs model.ExperimentCallbacks) {
callbacks = cbs
Expand Down

0 comments on commit b9390cf

Please sign in to comment.