omitempty is not null

This commit is contained in:
mr
2024-07-22 10:31:05 +02:00
parent 7f294374e8
commit bbe4b3eee7
365 changed files with 2879 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
package datacenter
import (
"testing"
resources "cloud.o-forge.io/core/oc-lib/models/resources"
"cloud.o-forge.io/core/oc-lib/models/utils"
"github.com/stretchr/testify/assert"
)
func TestStoreOneDatacenter(t *testing.T) {
dc := DatacenterResource{BookingPrice: 123,
AbstractResource: resources.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
Description: "Lorem Ipsum",
Logo: "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
dcma := DatacenterMongoAccessor{}
id, _, _ := dcma.StoreOne(&dc)
assert.NotEmpty(t, id)
}
func TestLoadOneDatacenter(t *testing.T) {
dc := DatacenterResource{BookingPrice: 123,
AbstractResource: resources.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
Description: "Lorem Ipsum",
Logo: "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
dcma := DatacenterMongoAccessor{}
new_dc, _, _ := dcma.StoreOne(&dc)
assert.Equal(t, dc, new_dc)
}

View File

@@ -0,0 +1 @@
{"version":1,"resource":"file:///home/mr/Documents/OC/oc-lib/models/resources/datacenter/datacenter_test.go","entries":[{"id":"nJ7l.go","timestamp":1721635662630},{"id":"0PV1.go","timestamp":1721635878916}]}

View File

@@ -0,0 +1,46 @@
package datacenter
import (
"testing"
resources "cloud.o-forge.io/core/oc-lib/models/resources"
"cloud.o-forge.io/core/oc-lib/models/utils"
"github.com/stretchr/testify/assert"
)
func TestStoreOneDatacenter(t *testing.T) {
dc := DatacenterResource{BookingPrice: 123,
AbstractResource: resources.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
Description: "Lorem Ipsum",
Logo: "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
dcma := DatacenterMongoAccessor{}
id, _, _ := dcma.StoreOne(&dc)
assert.NotEmpty(t, id)
}
func TestLoadOneDatacenter(t *testing.T) {
dc := DatacenterResource{BookingPrice: 123,
AbstractResource: resources.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
Description: "Lorem Ipsum",
Logo: "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
dcma := DatacenterMongoAccessor{}
new_dc, _, _ := dcma.StoreOne(&dc)
assert.Equal(t, dc, new_dc)
}