Skip to content

Commit

Permalink
fix: switch to use s.ctx for patch_test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackarySantana committed Dec 9, 2024
1 parent 4c6ac2e commit df9eb9f
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions trigger/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,60 +179,51 @@ func (s *patchSuite) TestAllTriggers() {
}

func (s *patchSuite) TestPatchSuccess() {
ctx, cancel := context.WithCancel(s.ctx)
defer cancel()

n, err := s.t.patchSuccess(ctx, &s.subs[1])
n, err := s.t.patchSuccess(s.ctx, &s.subs[1])
s.NoError(err)
s.Nil(n)

s.data.Status = evergreen.VersionFailed
n, err = s.t.patchSuccess(ctx, &s.subs[1])
n, err = s.t.patchSuccess(s.ctx, &s.subs[1])
s.NoError(err)
s.Nil(n)

s.data.Status = evergreen.VersionSucceeded
n, err = s.t.patchSuccess(ctx, &s.subs[1])
n, err = s.t.patchSuccess(s.ctx, &s.subs[1])
s.NoError(err)
s.NotNil(n)
}

func (s *patchSuite) TestPatchFailure() {
ctx, cancel := context.WithCancel(s.ctx)
defer cancel()

s.data.Status = evergreen.VersionCreated
n, err := s.t.patchFailure(ctx, &s.subs[2])
n, err := s.t.patchFailure(s.ctx, &s.subs[2])
s.NoError(err)
s.Nil(n)

s.data.Status = evergreen.VersionSucceeded
n, err = s.t.patchFailure(ctx, &s.subs[2])
n, err = s.t.patchFailure(s.ctx, &s.subs[2])
s.NoError(err)
s.Nil(n)

s.data.Status = evergreen.VersionFailed
n, err = s.t.patchFailure(ctx, &s.subs[2])
n, err = s.t.patchFailure(s.ctx, &s.subs[2])
s.NoError(err)
s.NotNil(n)
}

func (s *patchSuite) TestPatchOutcome() {
ctx, cancel := context.WithCancel(s.ctx)
defer cancel()

s.data.Status = evergreen.VersionCreated
n, err := s.t.patchOutcome(ctx, &s.subs[0])
n, err := s.t.patchOutcome(s.ctx, &s.subs[0])
s.NoError(err)
s.Nil(n)

s.data.Status = evergreen.VersionSucceeded
n, err = s.t.patchOutcome(ctx, &s.subs[0])
n, err = s.t.patchOutcome(s.ctx, &s.subs[0])
s.NoError(err)
s.NotNil(n)

s.data.Status = evergreen.VersionFailed
n, err = s.t.patchOutcome(ctx, &s.subs[0])
n, err = s.t.patchOutcome(s.ctx, &s.subs[0])
s.NoError(err)
s.NotNil(n)
}
Expand Down Expand Up @@ -273,47 +264,41 @@ func (s *patchSuite) TestRunChildrenOnPatchOutcome() {
for i := range s.subs {
s.NoError(s.subs[i].Upsert())
}
ctx, cancel := context.WithCancel(s.ctx)
defer cancel()

s.data.Status = evergreen.VersionSucceeded
n, err := s.t.patchOutcome(ctx, &s.subs[0])
n, err := s.t.patchOutcome(s.ctx, &s.subs[0])
// there is no token set up in settings, but hitting this error
// means it's trying to finalize the patch
s.Require().Error(err)
s.Contains(err.Error(), "finalizing child patch")
s.Nil(n)

s.data.Status = evergreen.VersionFailed
n, err = s.t.patchOutcome(ctx, &s.subs[1])
n, err = s.t.patchOutcome(s.ctx, &s.subs[1])
s.Require().Error(err)
s.Contains(err.Error(), "finalizing child patch")
s.Nil(n)

s.data.Status = evergreen.VersionSucceeded
n, err = s.t.patchOutcome(ctx, &s.subs[2])
n, err = s.t.patchOutcome(s.ctx, &s.subs[2])
s.Require().Error(err)
s.Contains(err.Error(), "finalizing child patch")
s.Nil(n)

s.data.Status = evergreen.VersionFailed
n, err = s.t.patchOutcome(ctx, &s.subs[2])
n, err = s.t.patchOutcome(s.ctx, &s.subs[2])
s.Require().Error(err)
s.Contains(err.Error(), "finalizing child patch")
s.Nil(n)

}

func (s *patchSuite) TestPatchStarted() {
ctx, cancel := context.WithCancel(s.ctx)
defer cancel()

n, err := s.t.patchStarted(ctx, &s.subs[0])
n, err := s.t.patchStarted(s.ctx, &s.subs[0])
s.Nil(err)
s.Nil(n)

s.data.Status = evergreen.VersionStarted
n, err = s.t.patchStarted(ctx, &s.subs[0])
n, err = s.t.patchStarted(s.ctx, &s.subs[0])
s.Nil(err)
s.NotNil(n)
}

0 comments on commit df9eb9f

Please sign in to comment.