Adjust + Test
This commit is contained in:
@@ -64,7 +64,8 @@ func TestPricedComputeResource_GetPriceHT(t *testing.T) {
|
||||
end := start.Add(1 * time.Hour)
|
||||
r := resources.PricedComputeResource{
|
||||
PricedResource: resources.PricedResource{
|
||||
ResourceID: "comp456",
|
||||
ResourceID: "comp456",
|
||||
SelectedPricing: &MockPricingProfile{ReturnCost: 1.0},
|
||||
BookingConfiguration: &resources.BookingConfiguration{
|
||||
UsageStart: &start,
|
||||
UsageEnd: &end,
|
||||
|
||||
@@ -92,6 +92,7 @@ func TestPricedDataResource_GetPriceHT(t *testing.T) {
|
||||
|
||||
r := &resources.PricedDataResource{
|
||||
PricedResource: resources.PricedResource{
|
||||
SelectedPricing: pricingProfile,
|
||||
BookingConfiguration: &resources.BookingConfiguration{
|
||||
UsageStart: &now,
|
||||
UsageEnd: &later,
|
||||
|
||||
@@ -105,14 +105,10 @@ func TestGetPriceHT(t *testing.T) {
|
||||
assert.Equal(t, 0.0, price)
|
||||
})
|
||||
|
||||
t.Run("uses first profile if selected is nil", func(t *testing.T) {
|
||||
start := time.Now()
|
||||
end := start.Add(30 * time.Minute)
|
||||
t.Run("defaults BookingConfiguration when nil", func(t *testing.T) {
|
||||
mock := &MockPricingProfile{ReturnCost: 42.0}
|
||||
r := &resources.PricedResource{
|
||||
BookingConfiguration: &resources.BookingConfiguration{
|
||||
UsageStart: &start,
|
||||
UsageEnd: &end,
|
||||
},
|
||||
SelectedPricing: mock,
|
||||
}
|
||||
price, err := r.GetPriceHT()
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -16,10 +16,11 @@ type MockInstance struct {
|
||||
resources.ResourceInstance[*MockPartner]
|
||||
}
|
||||
|
||||
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) GetID() string { return m.ID }
|
||||
func (m *MockInstance) GetName() string { return m.Name }
|
||||
func (m *MockInstance) ClearEnv() {}
|
||||
func (m *MockInstance) ClearPeerGroups() {}
|
||||
func (m *MockPartner) FilterPartnership(peerID string) {}
|
||||
func (m *MockInstance) GetProfile(peerID string, a *int, b *int, c *int) pricing.PricingProfileITF {
|
||||
return nil
|
||||
}
|
||||
@@ -36,10 +37,6 @@ type MockPartner struct {
|
||||
groups map[string][]string
|
||||
}
|
||||
|
||||
func (abs *MockPartner) RefineResourceByPartnership(peerID string) (resources.ResourcePartnerITF, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (m *MockPartner) GetProfile(buying *int, strategy *int) pricing.PricingProfileITF {
|
||||
return nil
|
||||
}
|
||||
@@ -48,6 +45,7 @@ func (m *MockPartner) GetPeerGroups() map[string][]string {
|
||||
return m.groups
|
||||
}
|
||||
func (m *MockPartner) ClearPeerGroups() {}
|
||||
|
||||
func (m *MockPartner) GetPricingsProfiles(string, []string) []pricing.PricingProfileITF {
|
||||
return nil
|
||||
}
|
||||
@@ -107,9 +105,9 @@ type FakeResource struct {
|
||||
resources.AbstractInstanciatedResource[*MockInstance]
|
||||
}
|
||||
|
||||
func (f *FakeResource) Trim() {}
|
||||
func (f *FakeResource) SetAllowedInstances(*tools.APIRequest) {}
|
||||
func (f *FakeResource) VerifyAuth(string, *tools.APIRequest) bool { return true }
|
||||
func (f *FakeResource) Trim() {}
|
||||
func (f *FakeResource) SetAllowedInstances(*tools.APIRequest, ...string) {}
|
||||
func (f *FakeResource) VerifyAuth(string, *tools.APIRequest) bool { return true }
|
||||
|
||||
func TestNewAccessor_ReturnsValid(t *testing.T) {
|
||||
acc := resources.NewAccessor[*FakeResource](tools.COMPUTE_RESOURCE, &tools.APIRequest{}, func() utils.DBObject {
|
||||
|
||||
Reference in New Issue
Block a user