Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
60
services/attendant/controllers/dtc_request_test.go
Normal file
60
services/attendant/controllers/dtc_request_test.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package controllers_test
|
||||
|
||||
import (
|
||||
"github.com/fiskerinc/cloud-services/services/attendant/controllers"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParsing(t *testing.T) {
|
||||
ecc := []byte(`{"ecu":"ECC","dtc":1719200,"status":9,"snapshot":"AQTv9ucIARIKNO/3AADv+AAAAADv+TLI"}`)
|
||||
icc := []byte(`{"ecu":"ICC","dtc":14302599,"status":9,"snapshot":"AQUFAAHv+AAAAADv+S2W7/cAAO/2B+cIChAB"}`)
|
||||
gw := []byte(`{"ecu":"GW","dtc":10718486,"status":8,"snapshot":"AQTv+QLA7/cAAO/2CAcHFAMs7/gAAAAA"}`)
|
||||
mcu := []byte(`{"ecu":"MCU","dtc":14123795,"status":47,"snapshot":"AQTv9ggHCRcBD+/3AADv+AAAAADv+TLI"}`)
|
||||
|
||||
check := func(ecu []byte) {
|
||||
var entry controllers.DTCEntry
|
||||
err := json.Unmarshal(ecu, &entry)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
entry.ParseSnapshot()
|
||||
if entry.Mileage != 0 {
|
||||
t.Errorf("Incorrect Mileage %d", entry.Mileage)
|
||||
}
|
||||
|
||||
fmt.Println(entry.Timestamp.Unix())
|
||||
switch entry.ECU {
|
||||
case "ECC":
|
||||
if entry.Timestamp.Unix() != 8730871852 {
|
||||
t.Errorf("Incorrect Timestamp %d", entry.Timestamp.Unix())
|
||||
}
|
||||
if entry.Voltage != 13 {
|
||||
t.Errorf("Incorrect Voltage %d", entry.Voltage)
|
||||
}
|
||||
case "ICC":
|
||||
if entry.Timestamp.Unix() != 1670580961 {
|
||||
t.Errorf("Incorrect Timestamp %d", entry.Timestamp.Unix())
|
||||
}
|
||||
if entry.Voltage != 11 {
|
||||
t.Errorf("Incorrect Voltage %d", entry.Voltage)
|
||||
}
|
||||
case "GW":
|
||||
if entry.Timestamp.Unix() != 1691525024 {
|
||||
t.Errorf("Incorrect Timestamp %d", entry.Timestamp.Unix())
|
||||
}
|
||||
case "MCU":
|
||||
if entry.Timestamp.Unix() != 1691708475 {
|
||||
t.Errorf("Incorrect Timestamp %d", entry.Timestamp.Unix())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
check(ecc)
|
||||
check(icc)
|
||||
check(gw)
|
||||
check(mcu)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user