44 "fmt"
55 "log"
66 "path/filepath"
7+ "strings"
78 "testing"
89 "time"
910
@@ -84,6 +85,11 @@ func TestTaskODSFinish(t *testing.T) {
8485 bitbucketClient := tasktesting .BitbucketClientOrFatal (t , ctxt .Clients .KubernetesClientSet , ctxt .Namespace )
8586 checkBuildStatus (t , bitbucketClient , ctxt .ODS .GitCommitSHA , bitbucket .BuildStatusSuccessful )
8687 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+ }
8793 },
8894 },
8995 "set bitbucket build status to successful and upload artifacts to permanent Nexus repository" : {
@@ -109,6 +115,23 @@ func TestTaskODSFinish(t *testing.T) {
109115 checkArtifactsAreInNexus (t , ctxt , nexus .PermanentRepositoryDefault )
110116 },
111117 },
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+ },
112135 },
113136 )
114137}
0 commit comments