Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
package tests
import (
"testing"
"fiskerinc.com/modules/common"
"fiskerinc.com/modules/validator"
)
func TestCANBusValidator(t *testing.T) {
bus := common.CANBus{
MemBuffSize: -20,
DiskBuffSize: -20,
}
err := validator.ValidateStruct(bus)
if err == nil {
t.Fail()
t.Log("No negative MemBuffSize of DiskBuffSize not enforced")
}
bus = common.CANBus{
Enabled: false,
MemBuffSize: 0,
DiskBuffSize: 0,
}
err = validator.ValidateStruct(bus)
if err != nil {
t.Fail()
t.Log("Failed with enabled false, and mem & disk buff at 0")
}
bus = common.CANBus{
Enabled: true,
MemBuffSize: 16777216,
DiskBuffSize: 1073741824,
}
err = validator.ValidateStruct(bus)
if err != nil {
t.Fail()
t.Log("Failed with enabled true, and mem & disk buff at minimum default")
}
bus = common.CANBus{
Enabled: true,
MemBuffSize: 16777216000000,
DiskBuffSize: 10737418240000000,
}
err = validator.ValidateStruct(bus)
if err == nil {
t.Fail()
t.Log("Expected Fail with enabled true, and mem & disk buff at very big numbers")
}
}