2024-07-18 11:51:12 +02:00
|
|
|
package data
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-11-28 11:05:54 +01:00
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resources/resource_model"
|
2024-07-19 10:54:58 +02:00
|
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
2024-11-28 13:19:01 +01:00
|
|
|
"cloud.o-forge.io/core/oc-lib/tools"
|
2024-07-18 13:35:14 +02:00
|
|
|
|
2024-07-18 11:51:12 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestStoreOneData(t *testing.T) {
|
2024-10-09 09:05:49 +02:00
|
|
|
d := DataResource{
|
|
|
|
WebResource: resource_model.WebResource{
|
2024-11-07 12:39:28 +01:00
|
|
|
Protocol: "http", Path: "azerty.fr",
|
2024-10-09 09:05:49 +02:00
|
|
|
},
|
|
|
|
Example: "123456",
|
2024-07-30 12:08:13 +02:00
|
|
|
AbstractResource: resource_model.AbstractResource{
|
2024-07-19 10:54:58 +02:00
|
|
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
|
|
|
Description: "Lorem Ipsum",
|
|
|
|
Logo: "azerty.com",
|
|
|
|
Owner: "toto",
|
|
|
|
OwnerLogo: "totoLogo",
|
|
|
|
SourceUrl: "azerty.fr",
|
2024-07-18 11:51:12 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-11-28 13:19:01 +01:00
|
|
|
dma := New(tools.DATA_RESOURCE, "", nil, nil)
|
2024-07-19 11:27:58 +02:00
|
|
|
id, _, _ := dma.StoreOne(&d)
|
2024-07-18 11:51:12 +02:00
|
|
|
|
|
|
|
assert.NotEmpty(t, id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLoadOneDate(t *testing.T) {
|
2024-10-09 09:05:49 +02:00
|
|
|
d := DataResource{
|
|
|
|
WebResource: resource_model.WebResource{
|
2024-11-07 12:39:28 +01:00
|
|
|
Protocol: "http", Path: "azerty.fr",
|
2024-10-09 09:05:49 +02:00
|
|
|
},
|
|
|
|
Example: "123456",
|
2024-07-30 12:08:13 +02:00
|
|
|
AbstractResource: resource_model.AbstractResource{
|
2024-07-19 10:54:58 +02:00
|
|
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
|
|
|
Description: "Lorem Ipsum",
|
|
|
|
Logo: "azerty.com",
|
|
|
|
Owner: "toto",
|
|
|
|
OwnerLogo: "totoLogo",
|
|
|
|
SourceUrl: "azerty.fr",
|
2024-07-18 11:51:12 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-11-28 13:19:01 +01:00
|
|
|
dma := New(tools.DATA_RESOURCE, "", nil, nil)
|
2024-07-19 11:27:58 +02:00
|
|
|
new_d, _, _ := dma.StoreOne(&d)
|
2024-07-18 11:51:12 +02:00
|
|
|
assert.Equal(t, d, new_d)
|
|
|
|
}
|