2d721baa91
These two small packages could easily be merged into the model package, since they're clearly model-like packages. Part of https://github.com/ooni/probe/issues/2115
27 lines
430 B
Go
27 lines
430 B
Go
package geolocate
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/apex/log"
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
)
|
|
|
|
func TestIPLookupWorksUsingcloudlflare(t *testing.T) {
|
|
ip, err := cloudflareIPLookup(
|
|
context.Background(),
|
|
http.DefaultClient,
|
|
log.Log,
|
|
model.HTTPHeaderUserAgent,
|
|
)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if net.ParseIP(ip) == nil {
|
|
t.Fatalf("not an IP address: '%s'", ip)
|
|
}
|
|
}
|