add some new files and services add hwtools that shows the current and last GWs - not yet included the user stats (if any available)
109 lines
2.8 KiB
Go
109 lines
2.8 KiB
Go
// This file was generated from JSON Schema using quicktype, do not modify it directly.
|
|
// To parse and unparse this JSON data, add this code to your project and do:
|
|
//
|
|
// qtmodels, err := UnmarshalQtmodels(bytes)
|
|
// bytes, err = qtmodels.Marshal()
|
|
|
|
package qtmodels
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestUnmarshalQtmodels(t *testing.T) {
|
|
defaultPath, _ := os.Getwd()
|
|
defaultPath, _ = filepath.Abs(defaultPath)
|
|
defaultPath = filepath.Join(defaultPath, "..", "..", "..", "data")
|
|
fs := []string{
|
|
defaultPath + "/arenaAttack_merged.json",
|
|
}
|
|
|
|
for _, v := range fs {
|
|
t.Run("json: "+string(v), func(t *testing.T) {
|
|
|
|
b, err := ioutil.ReadFile(v)
|
|
if err != nil {
|
|
t.Errorf("ioutil.ReadFile() error = %v", err)
|
|
return
|
|
}
|
|
|
|
qtmodels, err := UnmarshalQtmodels(b)
|
|
if err != nil {
|
|
t.Errorf("UnmarshalQtmodels() error = %v", err)
|
|
return
|
|
}
|
|
for _, qtmodel := range qtmodels {
|
|
if qtmodel.Request.Call.Name != "arenaAttack" {
|
|
t.Error(`qtmodel.Request.Call.Name != "arenaAttack"`)
|
|
return
|
|
}
|
|
}
|
|
//t.Logf("%#v", qtmodels)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestUnmarshalQtmodel(t *testing.T) {
|
|
defaultPath, _ := os.Getwd()
|
|
defaultPath, _ = filepath.Abs(defaultPath)
|
|
defaultPath = filepath.Join(defaultPath, "..", "..", "..", "data", "arenaAttack")
|
|
var fs []string
|
|
|
|
err := filepath.Walk(defaultPath, func(path string, info os.FileInfo, err error) error {
|
|
if !info.IsDir() {
|
|
fs = append(fs, path)
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
t.Errorf("Walk err = %v", err)
|
|
return
|
|
}
|
|
|
|
for _, v := range fs {
|
|
t.Run("json: "+string(v), func(t *testing.T) {
|
|
|
|
b, err := ioutil.ReadFile(v)
|
|
if err != nil {
|
|
t.Errorf("ioutil.ReadFile() error = %v", err)
|
|
return
|
|
}
|
|
|
|
qtmodel, err := UnmarshalQtmodel(b)
|
|
if err != nil {
|
|
t.Errorf("UnmarshalQtmodel() error = %v", err)
|
|
return
|
|
}
|
|
if qtmodel.Request.Call.Name != "arenaAttack" {
|
|
t.Error(`qtmodel.Request.Call.Name != "arenaAttack"`)
|
|
return
|
|
}
|
|
|
|
if qtmodel.Response.Result.Response != nil {
|
|
if qtmodel.Response.Result.Response.Battles != nil {
|
|
//t.Logf("%#v", qtmodel.Response.Result.Response.Battles)
|
|
if len(qtmodel.Response.Result.Response.Battles) != 1 {
|
|
t.Errorf(`len(qtmodel.Response.Result.Response.Battles) != 6 got %v`, len(qtmodel.Response.Result.Response.Battles))
|
|
return
|
|
}
|
|
for _, battle := range qtmodel.Response.Result.Response.Battles {
|
|
if len(battle.Attackers) == 0 {
|
|
t.Errorf(`range qtmodel.Response.Result.Response.Battles: battle.Attackers > 0 got %v`, len(battle.Attackers))
|
|
return
|
|
}
|
|
if len(battle.Defenders) == 0 {
|
|
t.Errorf(`range qtmodel.Response.Result.Response.Battles: battle.Defenders > 0 got %v`, len(battle.Defenders))
|
|
return
|
|
}
|
|
|
|
}
|
|
}
|
|
//t.Logf("%#v", qtmodels)
|
|
}
|
|
})
|
|
}
|
|
}
|