Add result summary support for IM tests

This commit is contained in:
Arturo Filastò 2018-03-23 15:22:58 +01:00
commit e56ce73006
4 changed files with 114 additions and 11 deletions

View file

@ -21,16 +21,36 @@ type WhatsAppSummary struct {
RegistrationServerBlocking bool
WebBlocking bool
EndpointsBlocking bool
Blocked bool
}
// Summary generates a summary for a test run
func (h WhatsApp) Summary(tk map[string]interface{}) interface{} {
const blk = "blocked"
var (
webBlocking bool
registrationBlocking bool
endpointsBlocking bool
)
var computeBlocking = func(key string) bool {
const blk = "blocked"
if tk[key] == nil {
return false
}
if tk[key].(string) == blk {
return true
}
return false
}
registrationBlocking = computeBlocking("registration_server_status")
webBlocking = computeBlocking("whatsapp_web_status")
endpointsBlocking = computeBlocking("whatsapp_endpoints_status")
return WhatsAppSummary{
RegistrationServerBlocking: tk["registration_server_status"].(string) == blk,
WebBlocking: tk["whatsapp_web_status"].(string) == blk,
EndpointsBlocking: tk["whatsapp_endpoints_status"].(string) == blk,
RegistrationServerBlocking: registrationBlocking,
WebBlocking: webBlocking,
EndpointsBlocking: endpointsBlocking,
Blocked: registrationBlocking || webBlocking || endpointsBlocking,
}
}