2024-11-07 11:05:24 +01:00
|
|
|
package compute
|
2024-07-18 11:51:12 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-07-30 12:08:13 +02:00
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
2024-07-19 10:54:58 +02:00
|
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
2024-07-18 13:35:14 +02:00
|
|
|
|
2024-07-18 11:51:12 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2024-11-07 11:05:24 +01:00
|
|
|
func TestStoreOneCompute(t *testing.T) {
|
|
|
|
dc := ComputeResource{
|
2024-07-30 12:08:13 +02:00
|
|
|
AbstractResource: resource_model.AbstractResource{
|
2024-11-07 11:05:24 +01:00
|
|
|
AbstractObject: utils.AbstractObject{Name: "testCompute"},
|
2024-07-19 10:54:58 +02:00
|
|
|
Description: "Lorem Ipsum",
|
|
|
|
Logo: "azerty.com",
|
|
|
|
Owner: "toto",
|
|
|
|
OwnerLogo: "totoLogo",
|
|
|
|
SourceUrl: "azerty.fr",
|
2024-07-18 11:51:12 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-07-31 10:07:55 +02:00
|
|
|
dcma := New()
|
2024-07-19 11:27:58 +02:00
|
|
|
id, _, _ := dcma.StoreOne(&dc)
|
2024-07-18 11:51:12 +02:00
|
|
|
|
|
|
|
assert.NotEmpty(t, id)
|
|
|
|
}
|
|
|
|
|
2024-11-07 11:05:24 +01:00
|
|
|
func TestLoadOneCompute(t *testing.T) {
|
|
|
|
dc := ComputeResource{
|
2024-07-30 12:08:13 +02:00
|
|
|
AbstractResource: resource_model.AbstractResource{
|
2024-11-07 11:05:24 +01:00
|
|
|
AbstractObject: utils.AbstractObject{Name: "testCompute"},
|
2024-07-19 10:54:58 +02:00
|
|
|
Description: "Lorem Ipsum",
|
|
|
|
Logo: "azerty.com",
|
|
|
|
Owner: "toto",
|
|
|
|
OwnerLogo: "totoLogo",
|
|
|
|
SourceUrl: "azerty.fr",
|
2024-07-18 11:51:12 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-07-31 10:07:55 +02:00
|
|
|
dcma := New()
|
2024-07-19 11:27:58 +02:00
|
|
|
new_dc, _, _ := dcma.StoreOne(&dc)
|
2024-07-18 11:51:12 +02:00
|
|
|
|
|
|
|
assert.Equal(t, dc, new_dc)
|
|
|
|
}
|