package workflow

import (
	"testing"

	"cloud.o-forge.io/core/oc-lib/models/utils"
	"cloud.o-forge.io/core/oc-lib/tools"
	"github.com/stretchr/testify/assert"
)

func TestNewWorkflowAccessor(t *testing.T) {
	req := &tools.APIRequest{}
	acc := NewAccessor(req)
	assert.NotNil(t, acc)
}

func TestWorkflow_StoreDraftDefault(t *testing.T) {
	w := &Workflow{
		AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
	}
	w.StoreDraftDefault()
	assert.False(t, w.IsDraft)
}

func TestWorkflow_VerifyAuth_NilRequest(t *testing.T) {
	w := &Workflow{
		AbstractObject: utils.AbstractObject{},
	}
	result := w.VerifyAuth("get", nil)
	assert.False(t, result)
}

func TestWorkflow_VerifyAuth_AdminRequest(t *testing.T) {
	w := &Workflow{}
	req := &tools.APIRequest{Admin: true}
	result := w.VerifyAuth("get", req)
	assert.True(t, result)
}
