Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Postgres store tests #1040

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
run: go test -mod readonly ./...
env:
JIMM_DSN: postgresql://jimm:jimm@localhost:5432/jimm
JIMM_TEST_PGXDSN: postgresql://jimm:jimm@localhost:5432/jimm
PGHOST: localhost
PGPASSWORD: jimm
PGSSLMODE: disable
Expand Down
1 change: 1 addition & 0 deletions internal/db/pgx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (s *postgresSuite) Init(c *qt.C) {
dsn := os.Getenv("JIMM_TEST_PGXDSN")
if dsn == "" {
c.Skip("postgresql not configured")
return
}

connCfg, err := pgx.ParseConfig(dsn)
Expand Down
6 changes: 3 additions & 3 deletions internal/db/secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *dbSuite) TestInsertSecret(c *qt.C) {
secret := dbmodel.Secret{}
tx := s.Database.DB.First(&secret)
c.Assert(tx.Error, qt.IsNil)
c.Assert(secret.Time, qt.Equals, testTime)
c.Assert(secret.Time, qt.DeepEquals, testTime)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised these tests weren't running before, I recall running them locally but I guess the CI was skipping them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you set the env then they weren't running locally either?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure they were, I remember going through iterations of them failing and fixing them

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that seems to be the reason.

c.Assert(secret.Type, qt.Equals, "generic")
c.Assert(secret.Tag, qt.Equals, "123")
c.Assert(secret.Data, qt.IsNil)
Expand Down Expand Up @@ -61,7 +61,7 @@ func (s *dbSuite) TestUpsertSecret(c *qt.C) {
secret := dbmodel.Secret{}
tx := s.Database.DB.First(&secret)
c.Assert(tx.Error, qt.IsNil)
c.Assert(secret.Time, qt.Equals, newTime)
c.Assert(secret.Time, qt.DeepEquals, newTime)
c.Assert([]byte(secret.Data), qt.DeepEquals, []byte("123"))
}

Expand All @@ -79,7 +79,7 @@ func (s *dbSuite) TestGetSecret(c *qt.C) {
c.Assert(s.Database.DB.Create(&u).Error, qt.IsNil)
secret := dbmodel.Secret{Type: "generic", Tag: "123"}
c.Assert(s.Database.GetSecret(ctx, &secret), qt.IsNil)
c.Assert(secret.Time, qt.Equals, testTime)
c.Assert(secret.Time, qt.DeepEquals, testTime)
c.Assert(secret.Type, qt.Equals, "generic")
c.Assert(secret.Tag, qt.Equals, "123")
}
Expand Down