Fix SCUM companion trajectory storage
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package companion
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCompanionVehicleHandlerCapabilityIsExplicitAndBounded(t *testing.T) {
|
||||
base := append([]string(nil), requiredCapabilities...)
|
||||
@@ -14,3 +18,29 @@ func TestCompanionVehicleHandlerCapabilityIsExplicitAndBounded(t *testing.T) {
|
||||
t.Fatal("undeclared raw command handler capability must be rejected")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadConfigDeclaresRawTrajectoryCollection(t *testing.T) {
|
||||
config := loadTestConfig(t)
|
||||
if !config.Trajectory.Enabled || config.Trajectory.Source != TrajectorySourceSCUMSQLite || config.Trajectory.Store != TrajectoryStoreSharedPlatformMySQL {
|
||||
t.Fatalf("trajectory collection is not enabled with plugin-owned source/store: %+v", config.Trajectory)
|
||||
}
|
||||
if config.Trajectory.FileEnv != SCUMDatabaseFileEnvironment || config.Trajectory.IntervalSeconds != DefaultTrajectoryCollectionIntervalSecs || config.Trajectory.MaxRows != DefaultTrajectoryCollectionMaxRows {
|
||||
t.Fatalf("trajectory collection did not use bounded defaults: %+v", config.Trajectory)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrajectoryConfigRejectsUnsafeEnvironmentNames(t *testing.T) {
|
||||
fixture := strings.ReplaceAll(string(mustReadConfigFixture(t)), "fileEnv: SCUM_DB_FILE", "fileEnv: PATH")
|
||||
if _, err := LoadConfig(strings.NewReader(fixture)); err == nil || !strings.Contains(err.Error(), "environment") {
|
||||
t.Fatalf("expected reserved env name to be rejected, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func mustReadConfigFixture(t *testing.T) []byte {
|
||||
t.Helper()
|
||||
payload, err := os.ReadFile("config.yaml.example")
|
||||
if err != nil {
|
||||
t.Fatalf("read config fixture: %v", err)
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user