out * 1 hour
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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{}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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]{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user