add sets up
This commit is contained in:
@@ -30,7 +30,7 @@ func TestComputeResource_ConvertToPricedResource(t *testing.T) {
|
||||
cr := &resources.ComputeResource{}
|
||||
cr.UUID = "comp123"
|
||||
cr.AbstractInstanciatedResource.UUID = cr.UUID
|
||||
result := cr.ConvertToPricedResource(tools.COMPUTE_RESOURCE, req, 0, 0)
|
||||
result := cr.ConvertToPricedResource(tools.COMPUTE_RESOURCE, req)
|
||||
assert.NotNil(t, result)
|
||||
assert.IsType(t, &resources.PricedComputeResource{}, result)
|
||||
}
|
||||
@@ -62,20 +62,9 @@ func TestComputeResourcePricingProfile_GetPrice_InvalidParams(t *testing.T) {
|
||||
func TestPricedComputeResource_GetPrice(t *testing.T) {
|
||||
start := time.Now()
|
||||
end := start.Add(1 * time.Hour)
|
||||
profile := &resources.ComputeResourcePricingProfile{
|
||||
CPUsPrices: map[string]float64{"Xeon": 1.0},
|
||||
GPUsPrices: map[string]float64{"Tesla": 2.0},
|
||||
RAMPrice: 0.5,
|
||||
ExploitPricingProfile: pricing.ExploitPricingProfile[pricing.TimePricingStrategy]{
|
||||
AccessPricingProfile: pricing.AccessPricingProfile[pricing.TimePricingStrategy]{
|
||||
Pricing: pricing.PricingStrategy[pricing.TimePricingStrategy]{Price: 1.0},
|
||||
},
|
||||
},
|
||||
}
|
||||
r := resources.PricedComputeResource{
|
||||
PricedResource: resources.PricedResource{
|
||||
ResourceID: "comp456",
|
||||
PricingProfiles: []pricing.PricingProfileITF{profile},
|
||||
UsageStart: &start,
|
||||
UsageEnd: &end,
|
||||
ExplicitBookingDurationS: 3600,
|
||||
|
||||
@@ -27,10 +27,10 @@ func TestDataResource_GetAccessor(t *testing.T) {
|
||||
func TestDataResource_ConvertToPricedResource(t *testing.T) {
|
||||
d := &resources.DataResource{}
|
||||
d.UUID = "123"
|
||||
res := d.ConvertToPricedResource(tools.DATA_RESOURCE, &tools.APIRequest{}, 0, 0)
|
||||
res := d.ConvertToPricedResource(tools.DATA_RESOURCE, &tools.APIRequest{})
|
||||
assert.IsType(t, &resources.PricedDataResource{}, res)
|
||||
|
||||
nilRes := d.ConvertToPricedResource(tools.PROCESSING_RESOURCE, &tools.APIRequest{}, 0, 0)
|
||||
nilRes := d.ConvertToPricedResource(tools.PROCESSING_RESOURCE, &tools.APIRequest{})
|
||||
assert.Nil(t, nilRes)
|
||||
}
|
||||
|
||||
@@ -94,9 +94,6 @@ func TestPricedDataResource_GetPrice(t *testing.T) {
|
||||
PricedResource: resources.PricedResource{
|
||||
UsageStart: &now,
|
||||
UsageEnd: &later,
|
||||
PricingProfiles: []pricing.PricingProfileITF{
|
||||
pricingProfile,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +101,9 @@ func TestGetPrice(t *testing.T) {
|
||||
t.Run("uses first profile if selected is nil", func(t *testing.T) {
|
||||
start := time.Now()
|
||||
end := start.Add(30 * time.Minute)
|
||||
mock := &MockPricingProfile{ReturnCost: 42.0}
|
||||
r := &resources.PricedResource{
|
||||
PricingProfiles: []pricing.PricingProfileITF{mock},
|
||||
UsageStart: &start,
|
||||
UsageEnd: &end,
|
||||
UsageStart: &start,
|
||||
UsageEnd: &end,
|
||||
}
|
||||
price, err := r.GetPrice()
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -20,7 +20,7 @@ func (m *MockInstance) GetID() string { return m.ID }
|
||||
func (m *MockInstance) GetName() string { return m.Name }
|
||||
func (m *MockInstance) ClearEnv() {}
|
||||
func (m *MockInstance) ClearPeerGroups() {}
|
||||
func (m *MockInstance) GetPricingsProfiles(string, []string, int, int) []pricing.PricingProfileITF {
|
||||
func (m *MockInstance) GetPricingsProfiles(string, []string) []pricing.PricingProfileITF {
|
||||
return nil
|
||||
}
|
||||
func (m *MockInstance) GetPeerGroups() ([]resources.ResourcePartnerITF, []map[string][]string) {
|
||||
@@ -37,7 +37,7 @@ func (m *MockPartner) GetPeerGroups() map[string][]string {
|
||||
return m.groups
|
||||
}
|
||||
func (m *MockPartner) ClearPeerGroups() {}
|
||||
func (m *MockPartner) GetPricingsProfiles(string, []string, int, int) []pricing.PricingProfileITF {
|
||||
func (m *MockPartner) GetPricingsProfiles(string, []string) []pricing.PricingProfileITF {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ func TestStorageResource_ConvertToPricedResource_ValidType(t *testing.T) {
|
||||
res := &resources.StorageResource{}
|
||||
res.AbstractInstanciatedResource.CreatorID = "creator"
|
||||
res.AbstractInstanciatedResource.UUID = "res-id"
|
||||
priced := res.ConvertToPricedResource(tools.STORAGE_RESOURCE, &tools.APIRequest{}, 0, 0)
|
||||
priced := res.ConvertToPricedResource(tools.STORAGE_RESOURCE, &tools.APIRequest{})
|
||||
assert.NotNil(t, priced)
|
||||
assert.IsType(t, &resources.PricedStorageResource{}, priced)
|
||||
}
|
||||
|
||||
func TestStorageResource_ConvertToPricedResource_InvalidType(t *testing.T) {
|
||||
res := &resources.StorageResource{}
|
||||
priced := res.ConvertToPricedResource(tools.COMPUTE_RESOURCE, &tools.APIRequest{}, 0, 0)
|
||||
priced := res.ConvertToPricedResource(tools.COMPUTE_RESOURCE, &tools.APIRequest{})
|
||||
assert.Nil(t, priced)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestWorkflowResource_ConvertToPricedResource(t *testing.T) {
|
||||
Groups: []string{"group1"},
|
||||
}
|
||||
|
||||
pr := w.ConvertToPricedResource(tools.WORKFLOW_RESOURCE, req, 0, 0)
|
||||
pr := w.ConvertToPricedResource(tools.WORKFLOW_RESOURCE, req)
|
||||
assert.Equal(t, "creator-id", pr.GetCreatorID())
|
||||
assert.Equal(t, tools.WORKFLOW_RESOURCE, pr.GetType())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user