Skip to content

Commit

Permalink
Make secret tests in state more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Sep 16, 2022
1 parent f192d6c commit 960f22a
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions state/secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ func (s *SecretsSuite) TestCreate(c *gc.C) {
}
md, err := s.store.CreateSecret(uri, p)
c.Assert(err, jc.ErrorIsNil)
c.Assert(md.URI.String(), gc.Equals, uri.String())
md.URI = nil
c.Assert(md, jc.DeepEquals, &secrets.SecretMetadata{
mc := jc.NewMultiChecker()
mc.AddExpr(`_.CreateTime`, jc.Almost, jc.ExpectedValue)
mc.AddExpr(`_.UpdateTime`, jc.Almost, jc.ExpectedValue)
c.Assert(md, mc, &secrets.SecretMetadata{
URI: uri,
Version: 1,
Description: "my secret",
Label: "foobar",
Expand Down Expand Up @@ -230,7 +232,10 @@ func (s *SecretsSuite) TestListByOwner(c *gc.C) {
OwnerTags: []names.Tag{s.owner.Tag(), names.NewApplicationTag("mariadb")},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(list, jc.DeepEquals, []*secrets.SecretMetadata{{
mc := jc.NewMultiChecker()
mc.AddExpr(`_.CreateTime`, jc.Almost, jc.ExpectedValue)
mc.AddExpr(`_.UpdateTime`, jc.Almost, jc.ExpectedValue)
c.Assert(list, mc, []*secrets.SecretMetadata{{
URI: uri,
RotatePolicy: secrets.RotateDaily,
NextRotateTime: ptr(next),
Expand Down Expand Up @@ -284,7 +289,10 @@ func (s *SecretsSuite) TestListByURI(c *gc.C) {
URI: uri,
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(list, jc.DeepEquals, []*secrets.SecretMetadata{{
mc := jc.NewMultiChecker()
mc.AddExpr(`_.CreateTime`, jc.Almost, jc.ExpectedValue)
mc.AddExpr(`_.UpdateTime`, jc.Almost, jc.ExpectedValue)
c.Assert(list, mc, []*secrets.SecretMetadata{{
URI: uri,
RotatePolicy: secrets.RotateDaily,
NextRotateTime: ptr(next),
Expand Down Expand Up @@ -334,7 +342,10 @@ func (s *SecretsSuite) TestListByConsumer(c *gc.C) {
ConsumerTags: []names.Tag{subject},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(list, jc.DeepEquals, []*secrets.SecretMetadata{{
mc := jc.NewMultiChecker()
mc.AddExpr(`_.CreateTime`, jc.Almost, jc.ExpectedValue)
mc.AddExpr(`_.UpdateTime`, jc.Almost, jc.ExpectedValue)
c.Assert(list, mc, []*secrets.SecretMetadata{{
URI: uri,
LatestRevision: 1,
Version: 1,
Expand Down Expand Up @@ -1581,7 +1592,7 @@ func (s *SecretsExpiryWatcherSuite) TestWatchSingleUpdate(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
for _, r := range revs {
if r.ExpireTime != nil && r.ExpireTime.Equal(update.ExpireTime.Round(time.Second).UTC()) {
c.Assert(r.UpdateTime, jc.DeepEquals, updated)
c.Assert(r.UpdateTime, jc.Almost, updated)
return
}
}
Expand Down

0 comments on commit 960f22a

Please sign in to comment.