@@ -14,6 +14,7 @@ import (
1414 "github.com/testcontainers/testcontainers-go/wait"
1515 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1616 "k8s.io/apimachinery/pkg/types"
17+ "k8s.io/utils/ptr"
1718
1819 "github.com/argoproj/argo-workflows/v4/config"
1920 wfv1 "github.com/argoproj/argo-workflows/v4/pkg/apis/workflow/v1alpha1"
@@ -33,7 +34,8 @@ var mysqlVariants = map[string]mysqlVariant{
3334 "MariaDB" : {image : "mariadb:11.4" , waitMessage : "mariadbd: ready for connections" },
3435}
3536
36- func setupMySQLArchiveTest (ctx context.Context , t * testing.T , v mysqlVariant ) (WorkflowArchive , func ()) {
37+ // setupMySQLArchiveTest starts a MySQL or MariaDB container, runs migrations, and returns a WorkflowArchive.
38+ func setupMySQLArchiveTest (ctx context.Context , t * testing.T , v mysqlVariant ) WorkflowArchive {
3739 t .Helper ()
3840
3941 c , err := testmysql .Run (ctx ,
@@ -48,6 +50,7 @@ func setupMySQLArchiveTest(ctx context.Context, t *testing.T, v mysqlVariant) (W
4850 )),
4951 )
5052 require .NoError (t , err )
53+ t .Cleanup (func () { testcontainers .TerminateContainer (c ) }) //nolint:errcheck
5154
5255 host , err := c .Host (ctx )
5356 require .NoError (t , err )
@@ -74,10 +77,9 @@ func setupMySQLArchiveTest(ctx context.Context, t *testing.T, v mysqlVariant) (W
7477 err = Migrate (ctx , proxy .Session (), "test" , "argo_workflows" , proxy .DBType ())
7578 require .NoError (t , err )
7679
77- return NewWorkflowArchive (proxy , "test" , "" , instanceid .NewService ("" )), func () {
78- proxy .Close ()
79- testcontainers .TerminateContainer (c ) //nolint:errcheck
80- }
80+ t .Cleanup (func () { proxy .Close () })
81+
82+ return NewWorkflowArchive (proxy , "test" , "" , instanceid .NewService ("" ))
8183}
8284
8385// TestMySQLListWorkflows verifies that JSON_EXTRACT/JSON_UNQUOTE queries in
@@ -90,8 +92,7 @@ func TestMySQLListWorkflows(t *testing.T) {
9092 for name , variant := range mysqlVariants {
9193 t .Run (name , func (t * testing.T ) {
9294 ctx := logging .TestContext (t .Context ())
93- archive , cleanup := setupMySQLArchiveTest (ctx , t , variant )
94- defer cleanup ()
95+ archive := setupMySQLArchiveTest (ctx , t , variant )
9596
9697 now := metav1 .Now ()
9798 err := archive .ArchiveWorkflow (ctx , & wfv1.Workflow {
@@ -106,6 +107,7 @@ func TestMySQLListWorkflows(t *testing.T) {
106107 },
107108 },
108109 Spec : wfv1.WorkflowSpec {
110+ Suspend : ptr .To (true ),
109111 Arguments : wfv1.Arguments {
110112 Parameters : []wfv1.Parameter {
111113 {Name : "msg" , Value : wfv1 .AnyStringPtr ("hello" )},
@@ -132,6 +134,7 @@ func TestMySQLListWorkflows(t *testing.T) {
132134 assert .Equal (t , wfv1 .Progress ("1/1" ), wf .Status .Progress )
133135 assert .Equal (t , "completed" , wf .Status .Message )
134136 assert .Equal (t , "test" , wf .GetLabels ()["env" ])
137+ assert .Equal (t , ptr .To (true ), wf .Spec .Suspend )
135138 })
136139 }
137140}
0 commit comments