55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package data
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"cloud.o-forge.io/core/oc-lib/models/resources/resource_model"
|
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
|
"cloud.o-forge.io/core/oc-lib/tools"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestStoreOneData(t *testing.T) {
|
|
d := DataResource{
|
|
WebResource: resource_model.WebResource{
|
|
Protocol: "http", Path: "azerty.fr",
|
|
},
|
|
Example: "123456",
|
|
AbstractResource: resource_model.AbstractResource{
|
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
|
Description: "Lorem Ipsum",
|
|
Logo: "azerty.com",
|
|
Owner: "toto",
|
|
OwnerLogo: "totoLogo",
|
|
SourceUrl: "azerty.fr",
|
|
},
|
|
}
|
|
|
|
dma := New(tools.DATA_RESOURCE, "", nil, nil)
|
|
id, _, _ := dma.StoreOne(&d)
|
|
|
|
assert.NotEmpty(t, id)
|
|
}
|
|
|
|
func TestLoadOneDate(t *testing.T) {
|
|
d := DataResource{
|
|
WebResource: resource_model.WebResource{
|
|
Protocol: "http", Path: "azerty.fr",
|
|
},
|
|
Example: "123456",
|
|
AbstractResource: resource_model.AbstractResource{
|
|
AbstractObject: utils.AbstractObject{Name: "testData"},
|
|
Description: "Lorem Ipsum",
|
|
Logo: "azerty.com",
|
|
Owner: "toto",
|
|
OwnerLogo: "totoLogo",
|
|
SourceUrl: "azerty.fr",
|
|
},
|
|
}
|
|
|
|
dma := New(tools.DATA_RESOURCE, "", nil, nil)
|
|
new_d, _, _ := dma.StoreOne(&d)
|
|
assert.Equal(t, d, new_d)
|
|
}
|