-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e38678d
commit 06d300f
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,51 @@ | ||
package engine | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"testing" | ||
|
||
"github.com/ooni/probe-cli/v3/internal/model" | ||
) | ||
|
||
func TestExperimentBuilderEngineWebConnectivity(t *testing.T) { | ||
// create a session for testing that does not use the network at all | ||
sess := newSessionForTestingNoLookups(t) | ||
|
||
// create an experiment builder for Web Connectivity | ||
builder, err := sess.NewExperimentBuilder("WebConnectivity") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// create suitable loader config | ||
config := &model.ExperimentTargetLoaderConfig{ | ||
CheckInConfig: &model.OOAPICheckInConfig{ | ||
// nothing | ||
}, | ||
Session: sess, | ||
StaticInputs: nil, | ||
SourceFiles: nil, | ||
} | ||
|
||
// create the loader | ||
loader := builder.NewTargetLoader(config) | ||
|
||
// create cancelled context to interrupt immediately so that we | ||
// don't use the network when running this test | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
cancel() | ||
|
||
// attempt to load targets | ||
targets, err := loader.Load(ctx) | ||
|
||
// make sure we've got the expected error | ||
if !errors.Is(err, context.Canceled) { | ||
t.Fatal("unexpected err", err) | ||
} | ||
|
||
// make sure there are no targets | ||
if len(targets) != 0 { | ||
t.Fatal("expected zero length targets") | ||
} | ||
} |