Skip to content

Commit

Permalink
fix: remove unrequired tests; add new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DecFox committed Feb 10, 2025
1 parent 2154d5f commit 73600c1
Showing 1 changed file with 8 additions and 36 deletions.
44 changes: 8 additions & 36 deletions internal/engine/session_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,56 +438,28 @@ func TestUserAgentNoProxy(t *testing.T) {
}
}

func TestNewOrchestraClientMaybeLookupBackendsFailure(t *testing.T) {
func TestNewOrchestraClientProbeServicesSuccess(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
errMocked := errors.New("mocked error")
sess := newSessionForTestingNoLookups(t)
sess.testMaybeLookupBackendsContext = func(ctx context.Context) error {
return errMocked
}
client, err := sess.newOrchestraClient(context.Background(), "https://api.dev.ooni.io")
if !errors.Is(err, errMocked) {
t.Fatal("not the error we expected", err)
}
if client != nil {
t.Fatal("expected nil client here")
_, err := sess.newOrchestraClient(context.Background(), "https://api.dev.ooni.io")
if err != nil {
t.Fatal(err)
}
}

func TestNewOrchestraClientMaybeLookupLocationFailure(t *testing.T) {
func TestNewOrchestraClientProbeServicesFailure(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
errMocked := errors.New("mocked error")
sess := newSessionForTestingNoLookups(t)
sess.testMaybeLookupLocationContext = func(ctx context.Context) error {
return errMocked
}
client, err := sess.newOrchestraClient(context.Background(), "https://api.dev.ooni.io")
if !errors.Is(err, errMocked) {
t.Fatalf("not the error we expected: %+v", err)
}
client, err := sess.newOrchestraClient(context.Background(), "https://api.stage.ooni.io")
if client != nil {
t.Fatal("expected nil client here")
}
}

func TestNewOrchestraClientProbeServicesNewClientFailure(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess := newSessionForTestingNoLookups(t)
sess.selectedProbeServiceHook = func(svc *model.OOAPIService) {
svc.Type = "antani" // should really not be supported for a long time
}
client, err := sess.newOrchestraClient(context.Background(), "https://api.dev.ooni.io")
if !errors.Is(err, probeservices.ErrUnsupportedServiceType) {
t.Fatal("not the error we expected")
}
if client != nil {
t.Fatal("expected nil client here")
if err == nil {
t.Fatal("expected non-nil error here")
}
}

Expand Down

0 comments on commit 73600c1

Please sign in to comment.