Fix summary package

This commit is contained in:
Arturo Filastò 2018-06-29 15:10:12 +02:00
parent cf588c8466
commit f75c53d404
2 changed files with 5 additions and 5 deletions

View File

@ -27,7 +27,7 @@ var NettestGroups = map[string]NettestGroup{
websites.WebConnectivity{}, websites.WebConnectivity{},
}, },
Summary: func(m summary.SummaryMap) (string, error) { Summary: func(m summary.SummaryMap) (string, error) {
if err := checkRequiredKeys([]string{"WebConnectivity"}, m); err != nil { if err := summary.CheckRequiredKeys([]string{"WebConnectivity"}, m); err != nil {
log.WithError(err).Error("missing keys") log.WithError(err).Error("missing keys")
return "", err return "", err
} }
@ -63,7 +63,7 @@ var NettestGroups = map[string]NettestGroup{
performance.NDT{}, performance.NDT{},
}, },
Summary: func(m summary.SummaryMap) (string, error) { Summary: func(m summary.SummaryMap) (string, error) {
if err := checkRequiredKeys([]string{"Dash", "Ndt"}, m); err != nil { if err := summary.CheckRequiredKeys([]string{"Dash", "Ndt"}, m); err != nil {
log.WithError(err).Error("missing keys") log.WithError(err).Error("missing keys")
return "", err return "", err
} }
@ -102,7 +102,7 @@ var NettestGroups = map[string]NettestGroup{
middlebox.HTTPHeaderFieldManipulation{}, middlebox.HTTPHeaderFieldManipulation{},
}, },
Summary: func(m summary.SummaryMap) (string, error) { Summary: func(m summary.SummaryMap) (string, error) {
if err := checkRequiredKeys([]string{"WebConnectivity"}, m); err != nil { if err := summary.CheckRequiredKeys([]string{"WebConnectivity"}, m); err != nil {
log.WithError(err).Error("missing keys") log.WithError(err).Error("missing keys")
return "", err return "", err
} }
@ -139,7 +139,7 @@ var NettestGroups = map[string]NettestGroup{
im.WhatsApp{}, im.WhatsApp{},
}, },
Summary: func(m summary.SummaryMap) (string, error) { Summary: func(m summary.SummaryMap) (string, error) {
if err := checkRequiredKeys([]string{"Whatsapp", "Telegram", "FacebookMessenger"}, m); err != nil { if err := summary.CheckRequiredKeys([]string{"Whatsapp", "Telegram", "FacebookMessenger"}, m); err != nil {
log.WithError(err).Error("missing keys") log.WithError(err).Error("missing keys")
return "", err return "", err
} }

View File

@ -33,7 +33,7 @@ type WebsitesSummary struct {
Blocked uint Blocked uint
} }
func checkRequiredKeys(rk []string, m SummaryMap) error { func CheckRequiredKeys(rk []string, m SummaryMap) error {
for _, key := range rk { for _, key := range rk {
if _, ok := m[key]; ok { if _, ok := m[key]; ok {
continue continue