organize + graph

This commit is contained in:
mr
2024-07-18 11:51:12 +02:00
parent 2eb74da9d2
commit 29a75bced9
69 changed files with 952 additions and 1531 deletions

29
models/models.go Normal file
View File

@@ -0,0 +1,29 @@
package models
import (
oclib "oc-lib"
r "oc-lib/models/resources"
d "oc-lib/models/resources/data"
dc "oc-lib/models/resources/datacenter"
p "oc-lib/models/resources/processing"
s "oc-lib/models/resources/storage"
"oc-lib/models/utils"
w "oc-lib/models/workflow"
)
var models = map[string]utils.DBObject{
w.WORKFLOW: &w.Workflow{},
r.ToString(r.DATA): &d.Data{},
r.ToString(r.DATACENTER): &dc.Datacenter{},
r.ToString(r.STORAGE): &s.Storage{},
r.ToString(r.PROCESSING): &p.Processing{},
}
func Model(model string) utils.DBObject {
log := oclib.CreateLogger("oclib", "")
if _, ok := models[model]; ok {
return models[model]
}
log.Error().Msg("Can't find model " + model + ".")
return nil
}

View File

@@ -0,0 +1,29 @@
package data
import (
resources "oc-lib/models/resources"
"oc-lib/models/utils"
)
type Data struct {
resources.AbstractResource
Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type
DataType string `json:"datatype" required:"true" bson:"datatype"`
Example string `json:"example" bson:"example" required:"true" validate:"required" description:"base64 encoded data"`
}
func (d *Data) GetType() resources.ResourceType {
return resources.DATA
}
func (d *Data) GetAccessor(driver utils.Driver) utils.Accessor {
var data utils.Accessor
switch driver {
case utils.MONGO:
data = &DataMongoAccessor{}
default:
data = &DataMongoAccessor{}
}
data.SetLogger()
return data
}

View File

@@ -0,0 +1,39 @@
package data
import (
mongo "oc-lib/dbs/mongo"
"oc-lib/models/utils"
)
type DataMongoAccessor struct {
utils.AbstractAccessor
}
func (dma *DataMongoAccessor) DeleteOne(id string) utils.DBObject {
return dma.GenericDeleteOne(id, dma)
}
func (dma *DataMongoAccessor) UpdateOne(set map[string]interface{}, id string) utils.DBObject {
return dma.GenericUpdateOne(set, id, dma)
}
func (dma *DataMongoAccessor) StoreOne(data utils.DBObject) utils.DBObject {
id, err := mongo.StoreOne(data.(*Data), "data")
if err != nil {
dma.Logger.Error().Msg("Could not store " + data.GetName() + " to db. Error: " + err.Error())
return &Data{}
}
return dma.LoadOne(id)
}
func (dma *DataMongoAccessor) LoadOne(id string) utils.DBObject {
var data Data
res_mongo, err := mongo.LoadOne(id, "data")
if err != nil {
dma.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return &Data{}
}
res_mongo.Decode(&data)
return &data
}

View File

@@ -0,0 +1,45 @@
package data
import (
resources "oc-lib/models/resources"
"testing"
"github.com/stretchr/testify/assert"
)
func TestStoreOneData(t *testing.T) {
d := Data{DataType: "jpeg", Example: "123456",
AbstractResource: resources.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: resources.AbstractResource{
Uuid: "123",
Name: "testData",
Description: "Lorem Ipsum",
Logo: "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
dma := DataMongoAccessor{}
new_d := dma.StoreOne(&d)
assert.Equal(t, d, new_d)
}

View File

@@ -0,0 +1,52 @@
package datacenter
import (
resources "oc-lib/models/resources"
"oc-lib/models/utils"
)
type Datacenter struct {
resources.AbstractResource
Owner string `bson:"owner" json:"owner" required:"true"`
BookingPrice int `bson:"booking_price" json:"booking_price" required:"true"`
CPU DatacenterCpuModel `bson:"cpu,omitempty" json:"cpu,omitempty"`
RAM DatacenterMemoryModel `bson:"ram,omitempty" json:"ram,omitempty"`
GPU []DatacenterGpuModel `bson:"gpu,omitempty" json:"gpu,omitempty"`
}
type DatacenterCpuModel struct {
Cores uint `bson:"cores,omitempty" json:"cores,omitempty"` //TODO: validate
Architecture string `bson:"architecture,omitempty" json:"architecture,omitempty"` //TOOD: enum
Shared bool `bson:"shared,omitempty" json:"shared,omitempty"`
MinimumMemory uint `bson:"minimum_memory,omitempty" json:"minimum_memory,omitempty"`
Platform string `bson:"platform,omitempty" json:"platform,omitempty"`
}
type DatacenterMemoryModel struct {
Size uint `bson:"size,omitempty" json:"size,omitempty" description:"Units in MB"`
Ecc bool `bson:"ecc,omitempty" json:"ecc,omitempty"`
}
type DatacenterGpuModel struct {
CudaCores uint `bson:"cuda_cores,omitempty" json:"cuda_cores,omitempty"`
Model string `bson:"model,omitempty" json:"model,omitempty"`
Memory uint `bson:"memory,omitempty" json:"memory,omitempty" description:"Units in MB"`
TensorCores uint `bson:"tensor_cores,omitempty" json:"tensor_cores,omitempty"`
}
func (d *Datacenter) GetType() resources.ResourceType {
return resources.DATACENTER
}
func (d *Datacenter) GetAccessor(driver utils.Driver) utils.Accessor {
var data utils.Accessor
switch driver {
case utils.MONGO:
data = &DatacenterMongoAccessor{}
default:
data = &DatacenterMongoAccessor{}
}
data.SetLogger()
return data
}

View File

@@ -0,0 +1,43 @@
package datacenter
import (
"oc-lib/dbs/mongo"
logs "oc-lib/logs"
"oc-lib/models/utils"
)
type DatacenterMongoAccessor struct {
utils.AbstractAccessor
}
func (dma *DatacenterMongoAccessor) DeleteOne(id string) utils.DBObject {
return dma.GenericDeleteOne(id, dma)
}
func (dma *DatacenterMongoAccessor) UpdateOne(set map[string]interface{}, id string) utils.DBObject {
return dma.GenericUpdateOne(set, id, dma)
}
func (dma *DatacenterMongoAccessor) StoreOne(data utils.DBObject) utils.DBObject {
id, err := mongo.StoreOne(data.(*Datacenter), "data")
if err != nil {
dma.Logger.Error().Msg("Could not store " + data.GetName() + " to db. Error: " + err.Error())
return &Datacenter{}
}
return dma.LoadOne(id)
}
func (dca *DatacenterMongoAccessor) LoadOne(id string) utils.DBObject {
var datacenter Datacenter
res_mongo, err := mongo.LoadOne(id, "datacenter")
if err != nil {
l := logs.CreateLogger("oclib", "")
l.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return &Datacenter{}
}
res_mongo.Decode(&datacenter)
return &datacenter
}

View File

@@ -0,0 +1,46 @@
package datacenter
import (
resources "oc-lib/models/resources"
"testing"
"github.com/stretchr/testify/assert"
)
func TestStoreOneDatacenter(t *testing.T) {
dc := Datacenter{Owner: "toto", BookingPrice: 123,
AbstractResource: resources.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: resources.AbstractResource{
Uuid: "123",
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,46 @@
package processing
import (
resources "oc-lib/models/resources"
"oc-lib/models/utils"
)
type Processing struct {
resources.AbstractResource
Container string `bson:"container,omitempty" json:"container,omitempty"` // We could create a specific class for container, that could check if the name exists/is available
Repository string `bson:"repository,omitempty" json:"repository,omitempty"` // Indicate where to find the container image => Could add a struct handling authentication to the repo
Command string `bson:"command,omitempty" json:"command,omitempty"`
Arguments []string `bson:"arguments,omitempty" json:"arguments,omitempty"`
Environment []map[string]string `bson:"environment,omitempty" json:"environment,omitempty"` // a key/value struct is what ressembles the most a NAME=VALUE struct
ExecutionRequirements ExecutionRequirementsModel `json:"execution_requirements,omitempty"`
Price uint `bson:"price,omitempty" json:"price,omitempty"`
License string `bson:"license,omitempty" json:"license,omitempty"`
}
type ExecutionRequirementsModel struct {
CPUs uint `bson:"cp_us,omitempty" json:"cp_us,omitempty"`
GPUs uint `bson:"gp_us,omitempty" json:"gp_us,omitempty"`
RAM uint `bson:"ram,omitempty" json:"ram,omitempty"`
Parallel bool `bson:"parallel,omitempty" json:"parallel,omitempty"`
ScalingModel uint `bson:"scaling_model,omitempty" json:"scaling_model,omitempty"`
DiskIO string `bson:"disk_io,omitempty" json:"disk_io,omitempty"`
}
func (p *Processing) GetType() resources.ResourceType {
return resources.PROCESSING
}
func (d *Processing) GetAccessor(driver utils.Driver) utils.Accessor {
var data utils.Accessor
switch driver {
case utils.MONGO:
data = &ProcessingMongoAccessor{}
default:
data = &ProcessingMongoAccessor{}
}
data.SetLogger()
return data
}

View File

@@ -0,0 +1,44 @@
package processing
import (
"oc-lib/dbs/mongo"
"oc-lib/logs"
"oc-lib/models/utils"
)
type ProcessingMongoAccessor struct {
utils.AbstractAccessor
}
func (dma *ProcessingMongoAccessor) DeleteOne(id string) utils.DBObject {
return dma.GenericDeleteOne(id, dma)
}
func (dma *ProcessingMongoAccessor) UpdateOne(set map[string]interface{}, id string) utils.DBObject {
return dma.GenericUpdateOne(set, id, dma)
}
func (dma *ProcessingMongoAccessor) StoreOne(data utils.DBObject) utils.DBObject {
id, err := mongo.StoreOne(data.(*Processing), "data")
if err != nil {
dma.Logger.Error().Msg("Could not store " + data.GetName() + " to db. Error: " + err.Error())
return &Processing{}
}
return dma.LoadOne(id)
}
func (pma *ProcessingMongoAccessor) LoadOne(id string) utils.DBObject {
var processing Processing
res_mongo, err := mongo.LoadOne(id, "processing")
if err != nil {
l := logs.CreateLogger("oclib", "")
l.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return &Processing{}
}
res_mongo.Decode(&processing)
return &processing
}

View File

@@ -0,0 +1,45 @@
package processing
import (
resources "oc-lib/models/resources"
"testing"
"github.com/stretchr/testify/assert"
)
func TestStoreOneProcessing(t *testing.T) {
p := Processing{Container: "totoCont",
AbstractResource: resources.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: resources.AbstractResource{
Uuid: "123",
Name: "testData",
Description: "Lorem Ipsum",
Logo: "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
sma := ProcessingMongoAccessor{}
new_s := sma.StoreOne(&p)
assert.Equal(t, p, new_s)
}

View File

@@ -0,0 +1,54 @@
package resources
// AbstractResource is the struct containing all of the attributes commons to all ressources
// Resource is the interface to be implemented by all classes inheriting from Resource to have the same behavior
//http://www.inanzzz.com/index.php/post/wqbs/a-basic-usage-of-int-and-string-enum-types-in-golang
type ResourceType int
const (
INVALID ResourceType = iota
DATA
PROCESSING
STORAGE
DATACENTER
WORKFLOW
)
var str = [...]string{
"invalid",
"data",
"processing",
"storage",
"datacenter",
"workflow",
}
func ToString(r ResourceType) string {
return str[r]
}
type Resource interface {
GetType() ResourceType
}
type AbstractResource struct {
Uuid string `json:"uuid" required:"true" bson:"uuid"`
Name string `json:"name" required:"true" bson:"name"`
ShortDescription string `json:"short_description" required:"true" bson:"short_description"`
Description string `json:"description,omitempty" bson:"description"`
Logo string `json:"logo" required:"true" bson:"logo"`
Owner string `json:"owner" required:"true" bson:"owner"`
OwnerLogo string `json:"owner_logo" required:"true" bson:"owner_logo"`
SourceUrl string `json:"source_url" required:"true" bson:"source_url"`
}
func (r *AbstractResource) GetID() string {
return r.Uuid
}
func (r *AbstractResource) GetName() string {
return r.Name
}

View File

@@ -0,0 +1,39 @@
package storage
import (
resources "oc-lib/models/resources"
"oc-lib/models/utils"
)
type URL struct {
Protocol string `bson:"protocol" json:"protocol"`
Path string `bson:"path" json:"path"`
}
type Storage struct {
resources.AbstractResource
Capacity uint `bson:"capacity,omitempty" json:"capacity,omitempty"`
Url URL `bson:"url,omitempty" json:"url,omitempty"` // Will allow to select between several protocols
Encryption bool `bson:"encryption,omitempty" json:"encryption,omitempty"`
Redundancy string `bson:"redundancy,omitempty" json:"redundancy,omitempty"`
Throughput string `bson:"throughput,omitempty" json:"throughput,omitempty"`
BookingPrice uint `bson:"booking_price,omitempty" json:"booking_price,omitempty"`
}
func (s *Storage) GetType() resources.ResourceType {
return resources.STORAGE
}
func (d *Storage) GetAccessor(driver utils.Driver) utils.Accessor {
var data utils.Accessor
switch driver {
case utils.MONGO:
data = &StorageMongoAccessor{}
default:
data = &StorageMongoAccessor{}
}
data.SetLogger()
return data
}

View File

@@ -0,0 +1,44 @@
package storage
import (
"oc-lib/dbs/mongo"
"oc-lib/logs"
"oc-lib/models/utils"
)
type StorageMongoAccessor struct {
utils.AbstractAccessor
}
func (dma *StorageMongoAccessor) DeleteOne(id string) utils.DBObject {
return dma.GenericDeleteOne(id, dma)
}
func (dma *StorageMongoAccessor) UpdateOne(set map[string]interface{}, id string) utils.DBObject {
return dma.GenericUpdateOne(set, id, dma)
}
func (dma *StorageMongoAccessor) StoreOne(data utils.DBObject) utils.DBObject {
id, err := mongo.StoreOne(data.(*Storage), "data")
if err != nil {
dma.Logger.Error().Msg("Could not store " + data.GetName() + " to db. Error: " + err.Error())
return &Storage{}
}
return dma.LoadOne(id)
}
func (schedulema *StorageMongoAccessor) LoadOne(id string) utils.DBObject {
var storage Storage
res_mongo, err := mongo.LoadOne(id, "storage")
if err != nil {
l := logs.CreateLogger("oclib", "")
l.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return &Storage{}
}
res_mongo.Decode(&storage)
return &storage
}

View File

@@ -0,0 +1,46 @@
package storage
import (
resources "oc-lib/models/resources"
"testing"
"github.com/stretchr/testify/assert"
)
func TestStoreOneStorage(t *testing.T) {
s := Storage{Capacity: 123, Url: URL{Protocol: "http", Path: "azerty.fr"},
AbstractResource: resources.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: resources.AbstractResource{
Uuid: "123",
Name: "testData",
Description: "Lorem Ipsum",
Logo: "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
sma := StorageMongoAccessor{}
new_s := sma.StoreOne(&s)
assert.Equal(t, s, new_s)
}

32
models/utils/abstracts.go Normal file
View File

@@ -0,0 +1,32 @@
package utils
import (
oclib "oc-lib"
"oc-lib/dbs/mongo"
"github.com/rs/zerolog"
)
type AbstractAccessor struct {
Logger zerolog.Logger
}
func (dma *AbstractAccessor) SetLogger() {
dma.Logger = oclib.CreateLogger("oclib", "")
}
func (dma *AbstractAccessor) GenericDeleteOne(id string, accessor Accessor) DBObject {
res := accessor.LoadOne(id)
_, err := mongo.DeleteOne(id, "data")
if err != nil {
dma.Logger.Error().Msg("Could not delete " + id + " to db. Error: " + err.Error())
}
return res
}
func (dma *AbstractAccessor) GenericUpdateOne(set map[string]interface{}, id string, accessor Accessor) DBObject {
id, err := mongo.UpdateOne(set, id, "data")
if err != nil {
dma.Logger.Error().Msg("Could not update " + id + " to db. Error: " + err.Error())
}
return accessor.LoadOne(id)
}

8
models/utils/enums.go Normal file
View File

@@ -0,0 +1,8 @@
package utils
type Driver int
const (
INVALID Driver = iota
MONGO
)

View File

@@ -0,0 +1,14 @@
package utils
type DBObject interface {
GetName() string
GetAccessor(driver Driver) Accessor
}
type Accessor interface {
SetLogger()
LoadOne(id string) DBObject
DeleteOne(id string) DBObject
StoreOne(data DBObject) DBObject
UpdateOne(set map[string]interface{}, id string) DBObject
}

View File

@@ -0,0 +1,41 @@
package graph
type Graph struct {
Items map[string]GraphItem `bson:"items" json:"items" default:"{}" required:"true"`
Links []GraphLink `bson:"links" json:"links" default:"{}" required:"true"`
}
type GraphItem struct {
ID string `bson:"ID" json:"ID" required:"true"`
Width float64 `bson:"width" json:"width" required:"true"`
Height float64 `bson:"height" json:"height" required:"true"`
Position Position `bson:"position" json:"position" required:"true"`
ResourceID string `bson:"resource_id" json:"resource_id" required:"true"`
}
type GraphLink struct {
Source Position `bson:"source" json:"source" required:"true"`
Destination Position `bson:"destination" json:"destination" required:"true"`
Style GraphLinkStyle `bson:"style" json:"style" required:"true"`
}
type GraphLinkStyle struct {
Color int64 `bson:"color" json:"color" required:"true"`
Stroke float64 `bson:"stroke" json:"stroke" required:"true"`
Tension float64 `bson:"tension" json:"tension"`
HeadRadius float64 `bson:"head_radius" json:"head_radius"`
DashWidth float64 `bson:"dash_width" json:"dash_width"`
DashSpace float64 `bson:"dash_space" json:"dash_space"`
EndArrow Position `bson:"end_arrow" json:"end_arrow"`
StartArrow Position `bson:"start_arrow" json:"start_arrow"`
ArrowStyle int64 `bson:"arrow_style" json:"arrow_style" required:"true"`
ArrowDirection int64 `bson:"arrow_direction" json:"arrow_direction" required:"true"`
StartArrowWidth float64 `bson:"start_arrow_style" json:"start_arrow_style"`
EndArrowWidth float64 `bson:"end_arrow_style" json:"end_arrow_style"`
}
type Position struct {
ID string `json:"ID" required:"true"`
X float64 `json:"x" required:"true"`
Y float64 `json:"y" required:"true"`
}

View File

@@ -0,0 +1,45 @@
package oclib
import (
"oc-lib/models/resources"
"oc-lib/models/resources/data"
"oc-lib/models/resources/datacenter"
"oc-lib/models/resources/processing"
"oc-lib/models/resources/storage"
"oc-lib/models/utils"
"oc-lib/models/workflow/graph"
)
const WORKFLOW = "workflow"
type Workflow struct {
resources.AbstractResource
Graph graph.Graph `bson:"graph,omitempty" json:"graph,omitempty"`
Datas map[string]data.Data `bson:"datas,omitempty" json:"datas,omitempty"`
Storages map[string]storage.Storage `bson:"storages,omitempty" json:"storages,omitempty"`
Processing map[string]processing.Processing `bson:"processing,omitempty" json:"processing,omitempty"`
Datacenters map[string]datacenter.Datacenter `bson:"datacenters,omitempty" json:"datacenters,omitempty"`
Schedule WorkflowSchedule `bson:"schedule,omitempty" json:"schedule,omitempty"`
}
func (d *Workflow) GetAccessor(driver utils.Driver) utils.Accessor {
var data utils.Accessor
switch driver {
case utils.MONGO:
data = &WorkflowMongoAccessor{}
default:
data = &WorkflowMongoAccessor{}
}
data.SetLogger()
return data
}
func (w *Workflow) isDCLink(link graph.GraphLink) bool {
if _, exists := w.Datacenters[link.Destination.ID]; exists {
return true
} else if _, exists := w.Datacenters[link.Source.ID]; exists {
return true
}
return false
}

View File

@@ -0,0 +1,43 @@
package oclib
import (
"oc-lib/dbs/mongo"
"oc-lib/logs"
"oc-lib/models/utils"
)
type WorkflowMongoAccessor struct {
utils.AbstractAccessor
}
func (dma *WorkflowMongoAccessor) DeleteOne(id string) utils.DBObject {
return dma.GenericDeleteOne(id, dma)
}
func (dma *WorkflowMongoAccessor) UpdateOne(set map[string]interface{}, id string) utils.DBObject {
return dma.GenericUpdateOne(set, id, dma)
}
func (dma *WorkflowMongoAccessor) StoreOne(data utils.DBObject) utils.DBObject {
id, err := mongo.StoreOne(data.(*Workflow), "data")
if err != nil {
dma.Logger.Error().Msg("Could not store " + data.GetName() + " to db. Error: " + err.Error())
return &Workflow{}
}
return dma.LoadOne(id)
}
func (wfa *WorkflowMongoAccessor) LoadOne(id string) utils.DBObject {
var workflow Workflow
res_mongo, err := mongo.LoadOne(id, "workflow")
if err != nil {
l := logs.CreateLogger("oclib", "")
l.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return &Workflow{}
}
res_mongo.Decode(&workflow)
return &workflow
}

View File

@@ -0,0 +1,15 @@
package oclib
import "time"
type WorkflowSchedule struct {
Id string `json:"id"`
Start time.Time
End time.Time
Cron string
}
func (ws *WorkflowSchedule) GetAllDates() (timetable []time.Time){
// Return all the execution time generated by the Cron
return
}

View File

@@ -0,0 +1,43 @@
package oclib
import (
"oc-lib/models/resources"
"testing"
"github.com/stretchr/testify/assert"
)
func TestStoreOneWorkflow(t *testing.T) {
w := Workflow{AbstractResource: resources.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: resources.AbstractResource{
Uuid: "123",
Name: "testWorkflow",
Description: "Lorem Ipsum",
Logo: "azerty.com",
Owner: "toto",
OwnerLogo: "totoLogo",
SourceUrl: "azerty.fr",
},
}
wma := WorkflowMongoAccessor{}
new_w := wma.StoreOne(&w)
assert.Equal(t, w, new_w)
}