@@ -723,3 +723,108 @@ func TestWorkflowHasArtifactGC(t *testing.T) {
723723 }
724724
725725}
726+
727+ func TestInlineWorkflowHasArtifactGC (t * testing.T ) {
728+ tests := []struct {
729+ name string
730+ workflowArtGCStrategySpec string
731+ artifactGCStrategySpec string
732+ expectedResult bool
733+ }{
734+ {
735+ name : "WorkflowSpecGC_Completion" ,
736+ workflowArtGCStrategySpec : `
737+ artifactGC:
738+ strategy: OnWorkflowCompletion` ,
739+ artifactGCStrategySpec : "" ,
740+ expectedResult : true ,
741+ },
742+ {
743+ name : "ArtifactSpecGC_Completion" ,
744+ workflowArtGCStrategySpec : "" ,
745+ artifactGCStrategySpec : `
746+ artifactGC:
747+ strategy: OnWorkflowCompletion` ,
748+ expectedResult : true ,
749+ },
750+ {
751+ name : "WorkflowSpecGC_Deletion" ,
752+ workflowArtGCStrategySpec : `
753+ artifactGC:
754+ strategy: OnWorkflowDeletion` ,
755+ artifactGCStrategySpec : "" ,
756+ expectedResult : true ,
757+ },
758+ {
759+ name : "ArtifactSpecGC_Deletion" ,
760+ workflowArtGCStrategySpec : "" ,
761+ artifactGCStrategySpec : `
762+ artifactGC:
763+ strategy: OnWorkflowDeletion` ,
764+ expectedResult : true ,
765+ },
766+ {
767+ name : "NoGC" ,
768+ workflowArtGCStrategySpec : "" ,
769+ artifactGCStrategySpec : "" ,
770+ expectedResult : false ,
771+ },
772+ {
773+ name : "WorkflowSpecGC_None" ,
774+ workflowArtGCStrategySpec : `
775+ artifactGC:
776+ strategy: ""` ,
777+ artifactGCStrategySpec : "" ,
778+ expectedResult : false ,
779+ },
780+ {
781+ name : "ArtifactSpecGC_None" ,
782+ workflowArtGCStrategySpec : `
783+ artifactGC:
784+ strategy: OnWorkflowDeletion` ,
785+ artifactGCStrategySpec : `
786+ artifactGC:
787+ strategy: Never` ,
788+ expectedResult : false ,
789+ },
790+ }
791+
792+ for _ , tt := range tests {
793+ t .Run (tt .name , func (t * testing.T ) {
794+
795+ workflowSpec := fmt .Sprintf (`apiVersion: argoproj.io/v1alpha1
796+ kind: Workflow
797+ metadata:
798+ generateName: artifact-passing-
799+ spec:
800+ entrypoint: whalesay
801+ %s
802+ templates:
803+ - name: whalesay
804+ steps:
805+ - - name: generate-artifact
806+ inline:
807+ container:
808+ image: docker/whalesay:latest
809+ command: [sh, -c]
810+ args: ["sleep 1; cowsay hello world | tee /tmp/hello_world.txt"]
811+ outputs:
812+ artifacts:
813+ - name: out
814+ path: /out
815+ s3:
816+ key: out
817+ %s` , tt .workflowArtGCStrategySpec , tt .artifactGCStrategySpec )
818+
819+ wf := wfv1 .MustUnmarshalWorkflow (workflowSpec )
820+ ctx := logging .TestContext (t .Context ())
821+ cancel , controller := newController (ctx , wf )
822+ defer cancel ()
823+ woc := newWorkflowOperationCtx (ctx , wf , controller )
824+
825+ hasArtifact := woc .HasArtifactGC ()
826+
827+ assert .Equal (t , tt .expectedResult , hasArtifact )
828+ })
829+ }
830+ }
0 commit comments