Upgrade to ooni/probe-engine@v0.1.1 (#60)
This commit is contained in:
@@ -11,8 +11,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-engine/model"
|
||||
"github.com/ooni/probe-cli/utils"
|
||||
"github.com/ooni/probe-cli/internal/enginex"
|
||||
"github.com/ooni/probe-cli/internal/util"
|
||||
"github.com/pkg/errors"
|
||||
db "upper.io/db.v3"
|
||||
@@ -256,14 +256,14 @@ func CreateResult(sess sqlbuilder.Database, homePath string, testGroupName strin
|
||||
}
|
||||
|
||||
// CreateNetwork will create a new network in the network table
|
||||
func CreateNetwork(sess sqlbuilder.Database, location *model.LocationInfo) (*Network, error) {
|
||||
func CreateNetwork(sess sqlbuilder.Database, loc enginex.LocationProvider) (*Network, error) {
|
||||
network := Network{
|
||||
ASN: location.ASN,
|
||||
CountryCode: location.CountryCode,
|
||||
NetworkName: location.NetworkName,
|
||||
ASN: loc.ProbeASN(),
|
||||
CountryCode: loc.ProbeCC(),
|
||||
NetworkName: loc.ProbeNetworkName(),
|
||||
// On desktop we consider it to always be wifi
|
||||
NetworkType: "wifi",
|
||||
IP: location.ProbeIP,
|
||||
IP: loc.ProbeIP(),
|
||||
}
|
||||
newID, err := sess.Collection("networks").Insert(network)
|
||||
if err != nil {
|
||||
|
||||
@@ -3,14 +3,46 @@ package database
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/ooni/probe-engine/model"
|
||||
db "upper.io/db.v3"
|
||||
)
|
||||
|
||||
type locationInfo struct {
|
||||
asn uint
|
||||
countryCode string
|
||||
ip string
|
||||
networkName string
|
||||
resolverIP string
|
||||
}
|
||||
|
||||
func (lp *locationInfo) ProbeASN() uint {
|
||||
return lp.asn
|
||||
}
|
||||
|
||||
func (lp *locationInfo) ProbeASNString() string {
|
||||
return fmt.Sprintf("AS%d", lp.asn)
|
||||
}
|
||||
|
||||
func (lp *locationInfo) ProbeCC() string {
|
||||
return lp.countryCode
|
||||
}
|
||||
|
||||
func (lp *locationInfo) ProbeIP() string {
|
||||
return lp.ip
|
||||
}
|
||||
|
||||
func (lp *locationInfo) ProbeNetworkName() string {
|
||||
return lp.networkName
|
||||
}
|
||||
|
||||
func (lp *locationInfo) ResolverIP() string {
|
||||
return lp.resolverIP
|
||||
}
|
||||
|
||||
func TestMeasurementWorkflow(t *testing.T) {
|
||||
tmpfile, err := ioutil.TempFile("", "dbtest")
|
||||
if err != nil {
|
||||
@@ -29,10 +61,10 @@ func TestMeasurementWorkflow(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
location := model.LocationInfo{
|
||||
ASN: 0,
|
||||
CountryCode: "IT",
|
||||
NetworkName: "Unknown",
|
||||
location := locationInfo{
|
||||
asn: 0,
|
||||
countryCode: "IT",
|
||||
networkName: "Unknown",
|
||||
}
|
||||
network, err := CreateNetwork(sess, &location)
|
||||
if err != nil {
|
||||
@@ -103,10 +135,10 @@ func TestDeleteResult(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
location := model.LocationInfo{
|
||||
ASN: 0,
|
||||
CountryCode: "IT",
|
||||
NetworkName: "Unknown",
|
||||
location := locationInfo{
|
||||
asn: 0,
|
||||
countryCode: "IT",
|
||||
networkName: "Unknown",
|
||||
}
|
||||
network, err := CreateNetwork(sess, &location)
|
||||
if err != nil {
|
||||
@@ -175,16 +207,16 @@ func TestNetworkCreate(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
l1 := model.LocationInfo{
|
||||
ASN: 2,
|
||||
CountryCode: "IT",
|
||||
NetworkName: "Antaninet",
|
||||
l1 := locationInfo{
|
||||
asn: 2,
|
||||
countryCode: "IT",
|
||||
networkName: "Antaninet",
|
||||
}
|
||||
|
||||
l2 := model.LocationInfo{
|
||||
ASN: 3,
|
||||
CountryCode: "IT",
|
||||
NetworkName: "Fufnet",
|
||||
l2 := locationInfo{
|
||||
asn: 3,
|
||||
countryCode: "IT",
|
||||
networkName: "Fufnet",
|
||||
}
|
||||
|
||||
_, err = CreateNetwork(sess, &l1)
|
||||
|
||||
Reference in New Issue
Block a user