diff --git a/postgres/README.md b/postgres/README.md index ee2be004..afee5fdd 100644 --- a/postgres/README.md +++ b/postgres/README.md @@ -16,7 +16,7 @@ func (s *Storage) Get(key string) ([]byte, error) func (s *Storage) Set(key string, val []byte, exp time.Duration) error func (s *Storage) Delete(key string) error func (s *Storage) Reset() error -func (s *Storage) Close() +func (s *Storage) Close() error ``` ### Installation Postgres is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet: diff --git a/postgres/postgres.go b/postgres/postgres.go index 054d0d92..4d6d52d8 100644 --- a/postgres/postgres.go +++ b/postgres/postgres.go @@ -172,10 +172,11 @@ func (s *Storage) Reset() error { } // Close the database -func (s *Storage) Close() { +func (s *Storage) Close() error { s.done <- struct{}{} s.db.Stat() s.db.Close() + return nil } // gcTicker starts the gc ticker @@ -208,8 +209,4 @@ func (s *Storage) checkSchema(tableName string) { if strings.ToLower(string(data)) != "bytea" { fmt.Printf(checkSchemaMsg, string(data)) } -} - -func (s *Storage) DB() *pgxpool.Pool { - return s.db -} +} \ No newline at end of file diff --git a/postgres/postgres_test.go b/postgres/postgres_test.go index 830cca76..b6b2cc39 100644 --- a/postgres/postgres_test.go +++ b/postgres/postgres_test.go @@ -174,3 +174,7 @@ func Test_SslRequiredMode(t *testing.T) { SslMode: "require", }) } + +func Test_Postgres_Close(t *testing.T) { + utils.AssertEqual(t, nil, testStore.Close()) +} \ No newline at end of file