init push
This commit is contained in:
68
internal/domain/fleet_status/model_test.go
Normal file
68
internal/domain/fleet_status/model_test.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package fleetstatus
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestTableNames(t *testing.T) {
|
||||
if (FleetStatus{}).TableName() != "fleet_statuses" {
|
||||
t.Error("FleetStatus table name")
|
||||
}
|
||||
if (MaintenanceSchedule{}).TableName() != "maintenance_schedules" {
|
||||
t.Error("MaintenanceSchedule table name")
|
||||
}
|
||||
if (FleetStatusFile{}).TableName() != "fleet_status_files" {
|
||||
t.Error("FleetStatusFile table name")
|
||||
}
|
||||
if (FleetStatusServiceLog{}).TableName() != "fleet_status_service_logs" {
|
||||
t.Error("FleetStatusServiceLog table name")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFleetStatusBeforeCreate(t *testing.T) {
|
||||
f := &FleetStatus{}
|
||||
if err := f.BeforeCreate(nil); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if len(f.ID) == 0 {
|
||||
t.Fatal("ID should be set")
|
||||
}
|
||||
if f.Status != StatusActive {
|
||||
t.Fatalf("Status default = %q, want %q", f.Status, StatusActive)
|
||||
}
|
||||
// existing ID + status preserved
|
||||
f2 := &FleetStatus{Status: "serviced"}
|
||||
_ = f2.BeforeCreate(nil)
|
||||
if f2.Status != "serviced" {
|
||||
t.Fatal("BeforeCreate must not overwrite an existing status")
|
||||
}
|
||||
}
|
||||
|
||||
func TestChildBeforeCreate(t *testing.T) {
|
||||
m := &MaintenanceSchedule{}
|
||||
_ = m.BeforeCreate(nil)
|
||||
if len(m.ID) == 0 {
|
||||
t.Error("MaintenanceSchedule ID not set")
|
||||
}
|
||||
fsf := &FleetStatusFile{}
|
||||
_ = fsf.BeforeCreate(nil)
|
||||
if len(fsf.ID) == 0 {
|
||||
t.Error("FleetStatusFile ID not set")
|
||||
}
|
||||
sl := &FleetStatusServiceLog{}
|
||||
_ = sl.BeforeCreate(nil)
|
||||
if len(sl.ID) == 0 {
|
||||
t.Error("FleetStatusServiceLog ID not set")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsValidFileCategory(t *testing.T) {
|
||||
for _, c := range []string{FileCategoryWB, FileCategoryBFI} {
|
||||
if !IsValidFileCategory(c) {
|
||||
t.Fatalf("%q should be valid", c)
|
||||
}
|
||||
}
|
||||
for _, c := range []string{"WB", "", "nope"} {
|
||||
if IsValidFileCategory(c) {
|
||||
t.Fatalf("%q should be invalid", c)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user