add sets up
This commit is contained in:
@@ -2,10 +2,8 @@ package resources_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/models"
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/pricing"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@@ -107,43 +105,3 @@ func TestPricedStorageResource_GetPrice_NoProfiles(t *testing.T) {
|
||||
_, err := res.GetPrice()
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestPricedStorageResource_GetPrice_WithPricing(t *testing.T) {
|
||||
now := time.Now()
|
||||
end := now.Add(2 * time.Hour)
|
||||
profile := &resources.StorageResourcePricingProfile{
|
||||
ExploitPricingProfile: pricing.ExploitPricingProfile[resources.StorageResourcePricingStrategy]{
|
||||
AccessPricingProfile: pricing.AccessPricingProfile[resources.StorageResourcePricingStrategy]{
|
||||
Pricing: pricing.PricingStrategy[resources.StorageResourcePricingStrategy]{
|
||||
BuyingStrategy: pricing.PAY_PER_USE,
|
||||
Price: 42.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
res := &resources.PricedStorageResource{
|
||||
PricedResource: resources.PricedResource{
|
||||
UsageStart: &now,
|
||||
UsageEnd: &end,
|
||||
PricingProfiles: []pricing.PricingProfileITF{profile},
|
||||
},
|
||||
UsageStorageGB: 1.0,
|
||||
}
|
||||
price, err := res.GetPrice()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 42.0, price)
|
||||
}
|
||||
|
||||
func TestStorageResourcePricingProfile_IsPurchased(t *testing.T) {
|
||||
p := &resources.StorageResourcePricingProfile{
|
||||
ExploitPricingProfile: pricing.ExploitPricingProfile[resources.StorageResourcePricingStrategy]{
|
||||
AccessPricingProfile: pricing.AccessPricingProfile[resources.StorageResourcePricingStrategy]{
|
||||
Pricing: pricing.PricingStrategy[resources.StorageResourcePricingStrategy]{BuyingStrategy: pricing.PAY_PER_USE},
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.False(t, p.IsPurchased())
|
||||
|
||||
p.Pricing.BuyingStrategy = pricing.UNLIMITED
|
||||
assert.True(t, p.IsPurchased())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user