package oclib

import (
	"testing"

	"cloud.o-forge.io/core/oc-lib/models/resource_model"
	"cloud.o-forge.io/core/oc-lib/models/utils"

	"github.com/stretchr/testify/assert"
)

func TestStoreOneWorkflow(t *testing.T) {
	w := WorkflowResource{AbstractResource: resource_model.AbstractResource{
		AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
		Description:    "Lorem Ipsum",
		Logo:           "azerty.com",
		Owner:          "toto",
		OwnerLogo:      "totoLogo",
		SourceUrl:      "azerty.fr",
	},
	}

	wma := New()
	id, _, _ := wma.StoreOne(&w)

	assert.NotEmpty(t, id)
}

func TestLoadOneWorkflow(t *testing.T) {
	w := WorkflowResource{AbstractResource: resource_model.AbstractResource{
		AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
		Description:    "Lorem Ipsum",
		Logo:           "azerty.com",
		Owner:          "toto",
		OwnerLogo:      "totoLogo",
		SourceUrl:      "azerty.fr",
	},
	}

	wma := New()
	new_w, _, _ := wma.StoreOne(&w)
	assert.Equal(t, w, new_w)
}
