cleanup: doh.powerdns.org is not working anymore (#924)

While there, `.../internal/sessionresolver` => `.../sessionresolver`

See https://github.com/ooni/probe/issues/2255
This commit is contained in:
Simone Basso 2022-09-02 14:44:23 +02:00 committed by GitHub
commit 1153850aca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 3 additions and 23 deletions

View file

@ -0,0 +1,44 @@
package sessionresolver
import (
"context"
"errors"
"io"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/ooni/probe-cli/v3/internal/model/mocks"
)
func TestTimeLimitedLookupSuccess(t *testing.T) {
expected := []string{"8.8.8.8", "8.8.4.4"}
re := &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
return expected, nil
},
}
ctx := context.Background()
out, err := timeLimitedLookup(ctx, re, "dns.google")
if err != nil {
t.Fatal(err)
}
if diff := cmp.Diff(expected, out); diff != "" {
t.Fatal(diff)
}
}
func TestTimeLimitedLookupFailure(t *testing.T) {
re := &mocks.Resolver{
MockLookupHost: func(ctx context.Context, domain string) ([]string, error) {
return nil, io.EOF
},
}
ctx := context.Background()
out, err := timeLimitedLookup(ctx, re, "dns.google")
if !errors.Is(err, io.EOF) {
t.Fatal("not the error we expected", err)
}
if out != nil {
t.Fatal("expected nil here")
}
}