Adjust + Test
This commit is contained in:
@@ -4,26 +4,35 @@ 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 TestStoreOneWorkflow(t *testing.T) {
|
||||
w := Workflow{
|
||||
AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
|
||||
}
|
||||
|
||||
wma := NewAccessor(nil)
|
||||
id, _, _ := wma.StoreOne(&w)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
func TestNewWorkflowAccessor(t *testing.T) {
|
||||
req := &tools.APIRequest{}
|
||||
acc := NewAccessor(req)
|
||||
assert.NotNil(t, acc)
|
||||
}
|
||||
|
||||
func TestLoadOneWorkflow(t *testing.T) {
|
||||
w := Workflow{
|
||||
func TestWorkflow_StoreDraftDefault(t *testing.T) {
|
||||
w := &Workflow{
|
||||
AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
|
||||
}
|
||||
|
||||
wma := NewAccessor(nil)
|
||||
new_w, _, _ := wma.StoreOne(&w)
|
||||
assert.Equal(t, w, new_w)
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user