oc-lib/data_test.go

46 lines
893 B
Go
Raw Normal View History

2024-07-16 10:56:36 +02:00
package oclib
import (
"testing"
2024-07-17 17:19:03 +02:00
"github.com/stretchr/testify/assert"
2024-07-16 10:56:36 +02:00
)
2024-07-17 17:19:03 +02:00
func TestStoreOneData(t *testing.T){
d := Data{DataType: "jpeg", Example: "123456",
AbstractResource: AbstractResource{
Uuid: "123",
Name: "testData",
Description: "Lorem Ipsum",
Logo : "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
dma := DataMongoAccessor{}
id := dma.StoreOne(d)
assert.NotEmpty(t, id)
}
func TestLoadOneDate(t *testing.T){
d := Data{DataType: "jpeg", Example: "123456",
AbstractResource: AbstractResource{
Uuid: "123",
Name: "testData",
Description: "Lorem Ipsum",
Logo : "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
2024-07-16 10:56:36 +02:00
2024-07-17 17:19:03 +02:00
dma := DataMongoAccessor{}
id := dma.StoreOne(d)
new_d := dma.LoadOne(id)
assert.Equal(t,d, new_d)
2024-07-16 10:56:36 +02:00
}