tests for each model

This commit is contained in:
pb
2024-07-17 17:19:03 +02:00
parent 562720089f
commit 4fd22dc131
5 changed files with 222 additions and 1 deletions

View File

@@ -2,8 +2,45 @@ package oclib
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPostOneData(t *testing.T){
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",
},
}
dma := DataMongoAccessor{}
id := dma.StoreOne(d)
new_d := dma.LoadOne(id)
assert.Equal(t,d, new_d)
}