tests for each model
This commit is contained in:
parent
562720089f
commit
4fd22dc131
39
data_test.go
39
data_test.go
@ -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)
|
||||
}
|
46
datacenter_test.go
Normal file
46
datacenter_test.go
Normal file
@ -0,0 +1,46 @@
|
||||
package oclib
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestStoreOneDatacenter(t *testing.T){
|
||||
dc := Datacenter{Owner: "toto", BookingPrice: 123,
|
||||
AbstractResource: AbstractResource{
|
||||
Uuid: "123",
|
||||
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 := Datacenter{Owner: "toto", BookingPrice: 123,
|
||||
AbstractResource: AbstractResource{
|
||||
Uuid: "123",
|
||||
Name: "testDatacenter",
|
||||
Description: "Lorem Ipsum",
|
||||
Logo : "azerty.com",
|
||||
Owner: "toto",
|
||||
OwnerLogo: "totoLogo",
|
||||
SourceUrl: "azerty.fr",
|
||||
},
|
||||
}
|
||||
|
||||
dcma := DatacenterMongoAccessor{}
|
||||
id := dcma.StoreOne(dc)
|
||||
new_dc := dcma.LoadOne(id)
|
||||
|
||||
assert.Equal(t,dc, new_dc)
|
||||
}
|
47
processing_test.go
Normal file
47
processing_test.go
Normal file
@ -0,0 +1,47 @@
|
||||
package oclib
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestStoreOneProcessing(t *testing.T){
|
||||
p := Processing{ Container: "totoCont",
|
||||
AbstractResource: AbstractResource{
|
||||
Uuid: "123",
|
||||
Name: "testData",
|
||||
Description: "Lorem Ipsum",
|
||||
Logo : "azerty.com",
|
||||
Owner: "toto",
|
||||
OwnerLogo: "totoLogo",
|
||||
SourceUrl: "azerty.fr",
|
||||
},
|
||||
}
|
||||
|
||||
sma := ProcessingMongoAccessor{}
|
||||
id := sma.StoreOne(p)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
}
|
||||
|
||||
func TestLoadOneProcessing(t *testing.T){
|
||||
p := Processing{ Container: "totoCont",
|
||||
AbstractResource: AbstractResource{
|
||||
Uuid: "123",
|
||||
Name: "testData",
|
||||
Description: "Lorem Ipsum",
|
||||
Logo : "azerty.com",
|
||||
Owner: "toto",
|
||||
OwnerLogo: "totoLogo",
|
||||
SourceUrl: "azerty.fr",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
sma := ProcessingMongoAccessor{}
|
||||
id := sma.StoreOne(p)
|
||||
new_s := sma.LoadOne(id)
|
||||
|
||||
assert.Equal(t,p, new_s)
|
||||
}
|
47
storage_test.go
Normal file
47
storage_test.go
Normal file
@ -0,0 +1,47 @@
|
||||
package oclib
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestStoreOneStorage(t *testing.T){
|
||||
s := Storage{ Capacity: 123, Url: URL{Protocol: "http",Path: "azerty.fr"} ,
|
||||
AbstractResource: AbstractResource{
|
||||
Uuid: "123",
|
||||
Name: "testData",
|
||||
Description: "Lorem Ipsum",
|
||||
Logo : "azerty.com",
|
||||
Owner: "toto",
|
||||
OwnerLogo: "totoLogo",
|
||||
SourceUrl: "azerty.fr",
|
||||
},
|
||||
}
|
||||
|
||||
sma := StorageMongoAccessor{}
|
||||
id := sma.StoreOne(s)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
}
|
||||
|
||||
func TestLoadOneStorage(t *testing.T){
|
||||
s := Storage{ Capacity: 123, Url: URL{Protocol: "http",Path: "azerty.fr"} ,
|
||||
AbstractResource: AbstractResource{
|
||||
Uuid: "123",
|
||||
Name: "testData",
|
||||
Description: "Lorem Ipsum",
|
||||
Logo : "azerty.com",
|
||||
Owner: "toto",
|
||||
OwnerLogo: "totoLogo",
|
||||
SourceUrl: "azerty.fr",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
sma := StorageMongoAccessor{}
|
||||
id := sma.StoreOne(s)
|
||||
new_s := sma.LoadOne(id)
|
||||
|
||||
assert.Equal(t,s, new_s)
|
||||
}
|
44
workflow_test.go
Normal file
44
workflow_test.go
Normal file
@ -0,0 +1,44 @@
|
||||
package oclib
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestStoreOneWorkflow(t *testing.T){
|
||||
w := Workflow{AbstractResource: AbstractResource{
|
||||
Uuid: "123",
|
||||
Name: "testWorkflow",
|
||||
Description: "Lorem Ipsum",
|
||||
Logo : "azerty.com",
|
||||
Owner: "toto",
|
||||
OwnerLogo: "totoLogo",
|
||||
SourceUrl: "azerty.fr",
|
||||
},
|
||||
}
|
||||
|
||||
wma := WorkflowMongoAccessor{}
|
||||
id := wma.StoreOne(w)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
}
|
||||
|
||||
func TestLoadOneWorkflow(t *testing.T){
|
||||
w := Workflow{AbstractResource: AbstractResource{
|
||||
Uuid: "123",
|
||||
Name: "testWorkflow",
|
||||
Description: "Lorem Ipsum",
|
||||
Logo : "azerty.com",
|
||||
Owner: "toto",
|
||||
OwnerLogo: "totoLogo",
|
||||
SourceUrl: "azerty.fr",
|
||||
},
|
||||
}
|
||||
|
||||
wma := WorkflowMongoAccessor{}
|
||||
id := wma.StoreOne(w)
|
||||
new_w := wma.LoadOne(id)
|
||||
|
||||
assert.Equal(t,w, new_w)
|
||||
}
|
Loading…
Reference in New Issue
Block a user