2024-07-18 11:51:12 +02:00
|
|
|
package data
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-07-18 13:35:14 +02:00
|
|
|
resources "cloud.o-forge.io/core/oc-lib/models/resources"
|
|
|
|
|
2024-07-18 11:51:12 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestStoreOneData(t *testing.T) {
|
|
|
|
d := Data{DataType: "jpeg", Example: "123456",
|
|
|
|
AbstractResource: resources.AbstractResource{
|
|
|
|
Uuid: "123",
|
|
|
|
Name: "testData",
|
|
|
|
Description: "Lorem Ipsum",
|
|
|
|
Logo: "azerty.com",
|
|
|
|
Owner: "toto",
|
|
|
|
OwnerLogo: "totoLogo",
|
|
|
|
SourceUrl: "azerty.fr",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
dma := DataMongoAccessor{}
|
2024-07-18 15:35:30 +02:00
|
|
|
id, _ := dma.StoreOne(&d)
|
2024-07-18 11:51:12 +02:00
|
|
|
|
|
|
|
assert.NotEmpty(t, id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLoadOneDate(t *testing.T) {
|
|
|
|
d := Data{DataType: "jpeg", Example: "123456",
|
|
|
|
AbstractResource: resources.AbstractResource{
|
|
|
|
Uuid: "123",
|
|
|
|
Name: "testData",
|
|
|
|
Description: "Lorem Ipsum",
|
|
|
|
Logo: "azerty.com",
|
|
|
|
Owner: "toto",
|
|
|
|
OwnerLogo: "totoLogo",
|
|
|
|
SourceUrl: "azerty.fr",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
dma := DataMongoAccessor{}
|
2024-07-18 15:35:30 +02:00
|
|
|
new_d, _ := dma.StoreOne(&d)
|
2024-07-18 11:51:12 +02:00
|
|
|
assert.Equal(t, d, new_d)
|
|
|
|
}
|