Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
54
pkg/common/tests/trex_config_test.go
Normal file
54
pkg/common/tests/trex_config_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user