Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
31
pkg/hwversion/setHWVersion_test.go
Normal file
31
pkg/hwversion/setHWVersion_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package hwversion
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"fiskerinc.com/modules/common"
|
||||
"fiskerinc.com/modules/db/queries/mocks"
|
||||
"github.com/go-playground/assert/v2"
|
||||
)
|
||||
|
||||
func TestSetHWVersion(t *testing.T) {
|
||||
manifest := &common.UpdateManifest{
|
||||
ECUs: []*common.UpdateManifestECU{{ECU: "TREX", HWVersions: []string{"TREXHW"}}, {ECU: "PKC", HWVersions: []string{"vPKC1", "vPKC2"}}, {ECU: "ADAS", HWVersions: []string{"adas", "adas2"}}},
|
||||
}
|
||||
mockCarsDB := mocks.MockCars{}
|
||||
mockCarsDB.SelectCarECUs = []common.CarECU{{ECU: "PKC", HWVersion: "vPKC1"}, {ECU: "ADAS", HWVersion: "adas2"}}
|
||||
err := SetHWVersion(manifest, "somevin", &mockCarsDB)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
expectedOutPut := &common.UpdateManifest{
|
||||
ECUs: []*common.UpdateManifestECU{{ECU: "TREX", HWVersion: "placeholder"}, {ECU: "PKC", HWVersion: "vPKC1"}, {ECU: "ADAS", HWVersion: "adas2"}},
|
||||
}
|
||||
|
||||
a, _ := json.Marshal(manifest.ECUs)
|
||||
b, _ := json.Marshal(expectedOutPut.ECUs)
|
||||
assert.Equal(t, string(a), string(b))
|
||||
}
|
||||
Reference in New Issue
Block a user