From dabbdc15d281bcd824edee370e5f86a9b021c32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Fri, 7 Sep 2018 14:06:08 +0200 Subject: [PATCH] Fix bug in the test creation workflow --- internal/database/actions.go | 2 ++ internal/database/actions_test.go | 15 ++++++++++++++- internal/database/models.go | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/database/actions.go b/internal/database/actions.go index 851ad4e..4235dd2 100644 --- a/internal/database/actions.go +++ b/internal/database/actions.go @@ -170,6 +170,8 @@ func CreateNetwork(sess sqlbuilder.Database, location *utils.LocationInfo) (*Net ASN: location.ASN, CountryCode: location.CountryCode, NetworkName: location.NetworkName, + // On desktop we consider it to always be wifi + NetworkType: "wifi", IP: location.IP, } newID, err := sess.Collection("networks").Insert(network) diff --git a/internal/database/actions_test.go b/internal/database/actions_test.go index 6cb1ec9..261e2e9 100644 --- a/internal/database/actions_test.go +++ b/internal/database/actions_test.go @@ -5,6 +5,8 @@ import ( "io/ioutil" "os" "testing" + + "github.com/ooni/probe-cli/utils" ) func TestMeasurementWorkflow(t *testing.T) { @@ -24,7 +26,18 @@ func TestMeasurementWorkflow(t *testing.T) { if err != nil { t.Error(err) } - result, err := CreateResult(sess, tmpdir, "websites", 0) + + location := utils.LocationInfo{ + ASN: 0, + CountryCode: "IT", + NetworkName: "Unknown", + } + network, err := CreateNetwork(sess, &location) + if err != nil { + t.Fatal(err) + } + + result, err := CreateResult(sess, tmpdir, "websites", network.ID) if err != nil { t.Fatal(err) } diff --git a/internal/database/models.go b/internal/database/models.go index 8cfe1e8..69b679d 100644 --- a/internal/database/models.go +++ b/internal/database/models.go @@ -15,6 +15,7 @@ import ( type Network struct { ID int64 `db:"id"` NetworkName string `db:"network_name"` + NetworkType string `db:"network_type"` IP string `db:"ip"` ASN uint `db:"asn"` CountryCode string `db:"country_code"`