fix: ensure experiments return nil when we want to submit (#654)
Since https://github.com/ooni/probe-cli/pull/527, if an experiment returns an error, the corresponding measurement is not submitted since the semantics of returning an error is that something fundamental went wrong (e.g., we could not parse the input URL). This diff ensures that all experiments only return and error when something fundamental was wrong and return nil otherwise. Reference issue: https://github.com/ooni/probe/issues/1808.
This commit is contained in:
@@ -2,7 +2,6 @@ package run
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/dnscheck"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
@@ -10,7 +9,6 @@ import (
|
||||
|
||||
type dnsCheckMain struct {
|
||||
Endpoints *dnscheck.Endpoints
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (m *dnsCheckMain) do(ctx context.Context, input StructuredInput,
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Package run contains code to run other experiments.
|
||||
//
|
||||
// This code is currently alpha.
|
||||
package run
|
||||
@@ -1,6 +1,3 @@
|
||||
// Package run contains code to run other experiments.
|
||||
//
|
||||
// This code is currently alpha.
|
||||
package run
|
||||
|
||||
import (
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestRunURLGetterWithCancelledContext(t *testing.T) {
|
||||
sess := &mockable.Session{MockableLogger: log.Log}
|
||||
callbacks := model.NewPrinterCallbacks(log.Log)
|
||||
err := measurer.Run(ctx, sess, measurement, callbacks)
|
||||
if err == nil {
|
||||
if err != nil { // here we expected nil b/c we want to submit the measurement
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(measurement.Extensions) != 6 {
|
||||
|
||||
Reference in New Issue
Block a user