From fafa1186c2d35a0636e8d688ec93eb24fc5c6be5 Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 20 Mar 2026 14:42:48 +0100 Subject: [PATCH] out * 1 hour --- models/booking/tests/booking_test.go | 4 ++-- models/common/pricing/pricing_strategy.go | 2 +- models/common/pricing/tests/pricing_test.go | 4 ++-- models/resources/compute.go | 2 +- models/resources/data.go | 2 +- models/resources/priced_resource.go | 2 +- models/resources/processing.go | 2 +- .../purchase_resource/tests/purchase_resource_test.go | 4 ++-- models/resources/storage.go | 2 +- models/resources/tests/compute_test.go | 4 ++-- models/resources/tests/data_test.go | 2 +- models/resources/tests/priced_resource_test.go | 8 ++++---- models/resources/tests/processing_test.go | 8 ++++---- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/models/booking/tests/booking_test.go b/models/booking/tests/booking_test.go index 62c23bc..fe1b56d 100644 --- a/models/booking/tests/booking_test.go +++ b/models/booking/tests/booking_test.go @@ -13,8 +13,8 @@ import ( ) func TestBooking_GetDurations(t *testing.T) { - start := time.Now().Add(-2 * time.Hour) - end := start.Add(1 * time.Hour) + start := time.Now().Add(-10 * time.Minute) + end := start.Add(5 * time.Minute) realStart := start.Add(30 * time.Minute) realEnd := realStart.Add(90 * time.Minute) diff --git a/models/common/pricing/pricing_strategy.go b/models/common/pricing/pricing_strategy.go index f1aff2a..a4828f0 100755 --- a/models/common/pricing/pricing_strategy.go +++ b/models/common/pricing/pricing_strategy.go @@ -112,7 +112,7 @@ func getAverageTimeInSecond(averageTimeInSecond float64, start time.Time, end *t fromAverageDuration := after.Sub(now).Seconds() var tEnd time.Time if end == nil { - tEnd = start.Add(1 * time.Hour) + tEnd = start.Add(5 * time.Minute) } else { tEnd = *end } diff --git a/models/common/pricing/tests/pricing_test.go b/models/common/pricing/tests/pricing_test.go index 7b26fac..08b4189 100644 --- a/models/common/pricing/tests/pricing_test.go +++ b/models/common/pricing/tests/pricing_test.go @@ -63,7 +63,7 @@ func Test_getAverageTimeInSecond_WithoutEnd(t *testing.T) { func TestBookingEstimation(t *testing.T) { start := time.Now() - end := start.Add(2 * time.Hour) + end := start.Add(10 * time.Minute) strategies := map[pricing.TimePricingStrategy]float64{ pricing.ONCE: 50, pricing.PER_HOUR: 10, @@ -102,7 +102,7 @@ func TestPricingStrategy_Getters(t *testing.T) { func TestPricingStrategy_GetPriceHT(t *testing.T) { start := time.Now() - end := start.Add(1 * time.Hour) + end := start.Add(5 * time.Minute) // SUBSCRIPTION case ps := pricing.PricingStrategy[DummyStrategy]{ diff --git a/models/resources/compute.go b/models/resources/compute.go index fe0936d..7b45e91 100755 --- a/models/resources/compute.go +++ b/models/resources/compute.go @@ -198,7 +198,7 @@ func (r *PricedComputeResource) GetPriceHT() (float64, error) { r.BookingConfiguration.UsageStart = &now } if r.BookingConfiguration.UsageEnd == nil { - add := r.BookingConfiguration.UsageStart.Add(time.Duration(1 * time.Hour)) + add := r.BookingConfiguration.UsageStart.Add(time.Duration(5 * time.Minute)) r.BookingConfiguration.UsageEnd = &add } pricing := r.SelectedPricing diff --git a/models/resources/data.go b/models/resources/data.go index 12e46c9..7479155 100755 --- a/models/resources/data.go +++ b/models/resources/data.go @@ -194,7 +194,7 @@ func (r *PricedDataResource) GetPriceHT() (float64, error) { r.BookingConfiguration.UsageStart = &now } if r.BookingConfiguration.UsageEnd == nil { - add := r.BookingConfiguration.UsageStart.Add(time.Duration(1 * time.Hour)) + add := r.BookingConfiguration.UsageStart.Add(time.Duration(5 * time.Minute)) r.BookingConfiguration.UsageEnd = &add } pricing := r.SelectedPricing diff --git a/models/resources/priced_resource.go b/models/resources/priced_resource.go index a412cd6..10277ca 100755 --- a/models/resources/priced_resource.go +++ b/models/resources/priced_resource.go @@ -140,7 +140,7 @@ func (r *PricedResource[T]) GetPriceHT() (float64, error) { r.BookingConfiguration.UsageStart = &now } if r.BookingConfiguration.UsageEnd == nil { - add := r.BookingConfiguration.UsageStart.Add(time.Duration(1 * time.Hour)) + add := r.BookingConfiguration.UsageStart.Add(time.Duration(5 * time.Minute)) r.BookingConfiguration.UsageEnd = &add } if any(r.SelectedPricing) == nil { diff --git a/models/resources/processing.go b/models/resources/processing.go index 43c80e7..7ba8afa 100755 --- a/models/resources/processing.go +++ b/models/resources/processing.go @@ -104,7 +104,7 @@ func (a *PricedProcessingResource) GetExplicitDurationInS() float64 { if a.IsService { return -1 } - return (1 * time.Hour).Seconds() + return (5 * time.Minute).Seconds() } return a.BookingConfiguration.UsageEnd.Sub(*a.BookingConfiguration.UsageStart).Seconds() } diff --git a/models/resources/purchase_resource/tests/purchase_resource_test.go b/models/resources/purchase_resource/tests/purchase_resource_test.go index 99b7184..7a35126 100644 --- a/models/resources/purchase_resource/tests/purchase_resource_test.go +++ b/models/resources/purchase_resource/tests/purchase_resource_test.go @@ -36,8 +36,8 @@ func TestCanUpdate(t *testing.T) { func TestCanDelete(t *testing.T) { now := time.Now().UTC() - past := now.Add(-1 * time.Hour) - future := now.Add(1 * time.Hour) + past := now.Add(-5 * time.Minute) + future := now.Add(5 * time.Minute) t.Run("nil EndDate", func(t *testing.T) { r := &purchase_resource.PurchaseResource{} diff --git a/models/resources/storage.go b/models/resources/storage.go index c27aa62..5dca1bb 100755 --- a/models/resources/storage.go +++ b/models/resources/storage.go @@ -216,7 +216,7 @@ func (r *PricedStorageResource) GetPriceHT() (float64, error) { r.BookingConfiguration.UsageStart = &now } if r.BookingConfiguration.UsageEnd == nil { - add := r.BookingConfiguration.UsageStart.Add(time.Duration(1 * time.Hour)) + add := r.BookingConfiguration.UsageStart.Add(time.Duration(5 * time.Minute)) r.BookingConfiguration.UsageEnd = &add } pricing := r.SelectedPricing diff --git a/models/resources/tests/compute_test.go b/models/resources/tests/compute_test.go index 9ea7330..4705d1c 100644 --- a/models/resources/tests/compute_test.go +++ b/models/resources/tests/compute_test.go @@ -37,7 +37,7 @@ func TestComputeResource_ConvertToPricedResource(t *testing.T) { func TestComputeResourcePricingProfile_GetPriceHT_CPUs(t *testing.T) { start := time.Now() - end := start.Add(1 * time.Hour) + end := start.Add(5 * time.Minute) profile := resources.ComputeResourcePricingProfile{ CPUsPrices: map[string]float64{"Xeon": 2.0}, ExploitPricingProfile: pricing.ExploitPricingProfile[pricing.TimePricingStrategy]{ @@ -61,7 +61,7 @@ func TestComputeResourcePricingProfile_GetPriceHT_InvalidParams(t *testing.T) { func TestPricedComputeResource_GetPriceHT(t *testing.T) { start := time.Now() - end := start.Add(1 * time.Hour) + end := start.Add(5 * time.Minute) r := resources.PricedComputeResource{ PricedResource: resources.PricedResource[*resources.ComputeResourcePricingProfile]{ ResourceID: "comp456", diff --git a/models/resources/tests/data_test.go b/models/resources/tests/data_test.go index aaa6751..755dfd4 100644 --- a/models/resources/tests/data_test.go +++ b/models/resources/tests/data_test.go @@ -82,7 +82,7 @@ func TestDataResourcePricingProfile_IsPurchased(t *testing.T) { func TestPricedDataResource_GetPriceHT(t *testing.T) { now := time.Now() - later := now.Add(1 * time.Hour) + later := now.Add(5 * time.Minute) mockPrice := 42.0 pricingProfile := &resources.DataResourcePricingProfile{AccessPricingProfile: pricing.AccessPricingProfile[resources.DataResourcePricingStrategy]{ diff --git a/models/resources/tests/priced_resource_test.go b/models/resources/tests/priced_resource_test.go index 57f66e0..b0a63d9 100644 --- a/models/resources/tests/priced_resource_test.go +++ b/models/resources/tests/priced_resource_test.go @@ -64,7 +64,7 @@ func TestGetAndSetLocationStartEnd(t *testing.T) { now := time.Now() r.SetLocationStart(now) - r.SetLocationEnd(now.Add(2 * time.Hour)) + r.SetLocationEnd(now.Add(10 * time.Minute)) assert.Equal(t, now, *r.GetLocationStart()) assert.Equal(t, now.Add(2*time.Hour), *r.GetLocationEnd()) @@ -81,7 +81,7 @@ func TestGetExplicitDurationInS(t *testing.T) { t.Run("computes duration from start and end", func(t *testing.T) { start := time.Now() - end := start.Add(2 * time.Hour) + end := start.Add(10 * time.Minute) r := &resources.PricedResource[pricing.PricingProfileITF]{ BookingConfiguration: &resources.BookingConfiguration{ UsageStart: &start, UsageEnd: &end, @@ -117,7 +117,7 @@ func TestGetPriceHT(t *testing.T) { t.Run("returns error if profile GetPriceHT fails", func(t *testing.T) { start := time.Now() - end := start.Add(1 * time.Hour) + end := start.Add(5 * time.Minute) mock := &MockPricingProfile{ReturnErr: true} r := &resources.PricedResource[pricing.PricingProfileITF]{ SelectedPricing: mock, @@ -133,7 +133,7 @@ func TestGetPriceHT(t *testing.T) { t.Run("uses SelectedPricing if set", func(t *testing.T) { start := time.Now() - end := start.Add(1 * time.Hour) + end := start.Add(5 * time.Minute) mock := &MockPricingProfile{ReturnCost: 10.0} r := &resources.PricedResource[pricing.PricingProfileITF]{ SelectedPricing: mock, diff --git a/models/resources/tests/processing_test.go b/models/resources/tests/processing_test.go index 6895b5a..f81f4c4 100644 --- a/models/resources/tests/processing_test.go +++ b/models/resources/tests/processing_test.go @@ -23,7 +23,7 @@ func TestPricedProcessingResource_GetType(t *testing.T) { func TestPricedProcessingResource_GetExplicitDurationInS(t *testing.T) { now := time.Now() - after := now.Add(2 * time.Hour) + after := now.Add(10 * time.Minute) tests := []struct { name string @@ -46,7 +46,7 @@ func TestPricedProcessingResource_GetExplicitDurationInS(t *testing.T) { }, }, }, - expected: float64((1 * time.Hour).Seconds()), + expected: float64((5 * time.Minute).Seconds()), }, { name: "Duration computed from start and end", @@ -58,7 +58,7 @@ func TestPricedProcessingResource_GetExplicitDurationInS(t *testing.T) { }, }, }, - expected: float64((2 * time.Hour).Seconds()), + expected: float64((10 * time.Minute).Seconds()), }, { name: "Explicit duration takes precedence", @@ -89,7 +89,7 @@ func TestProcessingResource_GetAccessor(t *testing.T) { func TestProcessingResourcePricingProfile_GetPriceHT(t *testing.T) { start := time.Now() - end := start.Add(2 * time.Hour) + end := start.Add(10 * time.Minute) mockPricing := pricing.AccessPricingProfile[pricing.TimePricingStrategy]{ Pricing: pricing.PricingStrategy[pricing.TimePricingStrategy]{ Price: 100.0,