Progress on schema and fixing unittests

This commit is contained in:
Arturo Filastò
2018-09-06 16:13:04 +02:00
parent a518ca79da
commit b75cee5e84
6 changed files with 130 additions and 123 deletions
+16 -5
View File
@@ -55,12 +55,23 @@ func init() {
return err
}
result, err := database.CreateResult(ctx.DB, ctx.Home, database.Result{
Name: *nettestGroup,
StartTime: time.Now().UTC(),
Country: ctx.Location.CountryCode,
network := database.Network{
ASN: ctx.Location.ASN,
CountryCode: ctx.Location.CountryCode,
NetworkName: ctx.Location.NetworkName,
ASN: fmt.Sprintf("%d", ctx.Location.ASN),
IP: ctx.Location.IP,
}
newID, err := ctx.DB.Collection("networks").Insert(network)
if err != nil {
log.WithError(err).Error("Failed to create the network row")
return nil
}
network.ID = newID.(int64)
result, err := database.CreateResult(ctx.DB, ctx.Home, database.Result{
TestGroupName: *nettestGroup,
StartTime: time.Now().UTC(),
NetworkID: network.ID,
})
if err != nil {
log.Errorf("DB result error: %s", err)