Files
cloud-services/pkg/common/hmi_tx_test.go

89 lines
1.8 KiB
Go

package common_test
import (
"testing"
"time"
"github.com/fiskerinc/cloud-services/pkg/common"
"github.com/fiskerinc/cloud-services/pkg/common/dbbasemodel"
"github.com/fiskerinc/cloud-services/pkg/testhelper"
)
func TestHMITXMessages(t *testing.T) {
schema := "file://" + testhelper.GetSchemaDirPath() + "/hmi/TXMessage.json"
now := time.Now()
tests := []testhelper.SchemaTest{
{
Name: "TestHMIVerifySalt",
Object: common.Message{
Handler: "verify",
Data: common.HMISessionData{
Salt: "testsalt",
},
},
},
{
Name: "TestHMIVerifySession",
Object: common.Message{
Handler: "verify",
Data: common.HMISessionData{
SessionID: "test_session_id",
},
},
},
{
Name: "TestHMIProfiles",
Object: common.Message{
Handler: "profiles",
Data: nil,
},
},
{
Name: "TestHMISettingsUpdate",
Object: common.Message{
Handler: "settings_update",
Data: common.HMISettingsUpdate{
DriverID: "valid-cognito-id-1",
Settings: []common.CarSetting{{
Name: "TESTSETTING",
Value: "TESTVALUE",
Type: "string",
DBModelBase: dbbasemodel.DBModelBase{
UpdatedAt: &now,
},
}},
},
},
},
{
Name: "TestHMIPOIs",
Object: common.Message{
Handler: "user_pois",
Data: common.HMIPOIsMessage{
DriverID: "valid-cognito-id-1",
UserPOIs: []common.PointOfInterest{
{
Name: "TestWorkPOI",
Location: common.POILocation{
Latitude: 1.11,
Longitude: 2.22,
},
},
{
Name: "TestHomePOI",
Location: common.POILocation{
Latitude: 8.88,
Longitude: 9.99,
},
},
},
},
},
},
}
testhelper.NewSchemaTestHelper(t, schema).
RunSchemaTests(tests)
}