4
4
"fmt"
5
5
"log"
6
6
"path/filepath"
7
+ "strings"
7
8
"testing"
8
9
"time"
9
10
@@ -84,6 +85,11 @@ func TestTaskODSFinish(t *testing.T) {
84
85
bitbucketClient := tasktesting .BitbucketClientOrFatal (t , ctxt .Clients .KubernetesClientSet , ctxt .Namespace )
85
86
checkBuildStatus (t , bitbucketClient , ctxt .ODS .GitCommitSHA , bitbucket .BuildStatusSuccessful )
86
87
checkArtifactsAreInNexus (t , ctxt , nexus .TemporaryRepositoryDefault )
88
+
89
+ wantLogMsg := "Artifact coverage.out is already present in Nexus repository"
90
+ if ! strings .Contains (string (ctxt .CollectedLogs ), wantLogMsg ) {
91
+ t .Fatalf ("Want:\n %s\n \n Got:\n %s" , wantLogMsg , string (ctxt .CollectedLogs ))
92
+ }
87
93
},
88
94
},
89
95
"set bitbucket build status to successful and upload artifacts to permanent Nexus repository" : {
@@ -109,6 +115,23 @@ func TestTaskODSFinish(t *testing.T) {
109
115
checkArtifactsAreInNexus (t , ctxt , nexus .PermanentRepositoryDefault )
110
116
},
111
117
},
118
+ "stops gracefully when context cannot be read" : {
119
+ WorkspaceDirMapping : map [string ]string {"source" : "empty" },
120
+ PreRunFunc : func (t * testing.T , ctxt * tasktesting.TaskRunContext ) {
121
+ ctxt .Params = map [string ]string {
122
+ "pipeline-run-name" : "foo" ,
123
+ "aggregate-tasks-status" : "Failed" ,
124
+ }
125
+ },
126
+ WantRunSuccess : false ,
127
+ PostRunFunc : func (t * testing.T , ctxt * tasktesting.TaskRunContext ) {
128
+ want := "Unable to continue as pipeline context cannot be read"
129
+
130
+ if ! strings .Contains (string (ctxt .CollectedLogs ), want ) {
131
+ t .Fatalf ("Want:\n %s\n \n Got:\n %s" , want , string (ctxt .CollectedLogs ))
132
+ }
133
+ },
134
+ },
112
135
},
113
136
)
114
137
}
0 commit comments