init push
This commit is contained in:
36
internal/domain/helicopter_usage/model_test.go
Normal file
36
internal/domain/helicopter_usage/model_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package helicopter_usage
|
||||
|
||||
import "testing"
|
||||
|
||||
func f64(v float64) *float64 { return &v }
|
||||
|
||||
func TestApplyManualSummary_SeedBackComputed(t *testing.T) {
|
||||
h := &HelicopterUsage{TotalAirframeHours: 5} // aggregated 5, manual 0
|
||||
h.ApplyManualSummary(ManualSummaryInput{AirframeHours: f64(6000)})
|
||||
if h.TotalAirframeHours != 6000 {
|
||||
t.Fatalf("total = %v, want 6000", h.TotalAirframeHours)
|
||||
}
|
||||
if h.ManualAirframeHours != 5995 {
|
||||
t.Fatalf("manual = %v, want 5995 (6000-5)", h.ManualAirframeHours)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyManualSummary_NewFlightAccumulates(t *testing.T) {
|
||||
h := &HelicopterUsage{TotalAirframeHours: 5}
|
||||
h.ApplyManualSummary(ManualSummaryInput{AirframeHours: f64(6000)})
|
||||
// a new +10h flight raises aggregated from 5 to 15; RefreshAll recomputes Total = aggregated + manual.
|
||||
if got := 15.0 + h.ManualAirframeHours; got != 6010 {
|
||||
t.Fatalf("post-flight total = %v, want 6010", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyManualSummary_CccDirectAndNilUntouched(t *testing.T) {
|
||||
h := &HelicopterUsage{TotalEngine1Ccc: 2, TotalLanding: 100}
|
||||
h.ApplyManualSummary(ManualSummaryInput{Engine1Ccc: f64(44)})
|
||||
if h.TotalEngine1Ccc != 44 {
|
||||
t.Fatalf("ccc = %v, want 44", h.TotalEngine1Ccc)
|
||||
}
|
||||
if h.ManualEngine1GpcNgN1 != 0 || h.TotalLanding != 100 {
|
||||
t.Fatal("nil inputs must leave fields untouched")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user