mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-09-27 10:02:10 +08:00
test: added tests for workflow executions and creating workflow templates
This commit is contained in:
60
pkg/workflow_execution_test.go
Normal file
60
pkg/workflow_execution_test.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestClient_CreateWorkflowExecution(t *testing.T) {
|
||||
c := DefaultTestClient()
|
||||
clearDatabase(t)
|
||||
|
||||
namespace := "onepanel"
|
||||
|
||||
wt := &WorkflowTemplate{
|
||||
Name: "test",
|
||||
Manifest: defaultWorkflowTemplate,
|
||||
}
|
||||
wt, _ = c.CreateWorkflowTemplate(namespace, wt)
|
||||
|
||||
we := &WorkflowExecution{
|
||||
Name: "test",
|
||||
}
|
||||
|
||||
we, err := c.CreateWorkflowExecution(namespace, we, wt)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
// TestClient_ArchiveWorkflowExecution_NotExist makes sure there is no error if the workflow
|
||||
// execution does not exist
|
||||
func TestClient_ArchiveWorkflowExecution_NotExist(t *testing.T) {
|
||||
c := DefaultTestClient()
|
||||
clearDatabase(t)
|
||||
|
||||
err := c.ArchiveWorkflowExecution("onepanel-no-exist", "test-no-exist")
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
// TestClient_ArchiveWorkflowExecution_Exist makes sure we archive an existing workflow execution correctly
|
||||
func TestClient_ArchiveWorkflowExecution_Exist(t *testing.T) {
|
||||
c := DefaultTestClient()
|
||||
clearDatabase(t)
|
||||
|
||||
namespace := "onepanel"
|
||||
weName := "test"
|
||||
|
||||
wt := &WorkflowTemplate{
|
||||
Name: "test",
|
||||
Manifest: defaultWorkflowTemplate,
|
||||
}
|
||||
wt, _ = c.CreateWorkflowTemplate(namespace, wt)
|
||||
|
||||
we := &WorkflowExecution{
|
||||
Name: weName,
|
||||
}
|
||||
|
||||
we, err := c.CreateWorkflowExecution(namespace, we, wt)
|
||||
|
||||
err = c.ArchiveWorkflowExecution(namespace, weName)
|
||||
assert.Nil(t, err)
|
||||
}
|
Reference in New Issue
Block a user