• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

a1y-developer / doc-formatter / 20615518441

31 Dec 2025 08:45AM UTC coverage: 65.274% (-2.5%) from 67.802%
20615518441

Pull #23

github

web-flow
Merge 927ec1ce0 into 3f7df65bc
Pull Request #23: feat: upload to s3

293 of 507 new or added lines in 30 files covered. (57.79%)

3 existing lines in 2 files now uncovered.

906 of 1388 relevant lines covered (65.27%)

0.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pkg/persistence/util.go
1
package persistence
2

3
import (
4
        "testing"
5

6
        "github.com/DATA-DOG/go-sqlmock"
7
        "github.com/stretchr/testify/require"
8
        "gorm.io/driver/postgres"
9
        "gorm.io/gorm"
10
)
11

12
// GetMockDB create a mock database connection
NEW
13
func GetMockDB() (*gorm.DB, sqlmock.Sqlmock, error) {
×
NEW
14
        // Create a sqlMock of sql.DB.
×
NEW
15
        fakeDB, sqlMock, err := sqlmock.New()
×
NEW
16
        if err != nil {
×
NEW
17
                return nil, nil, err
×
NEW
18
        }
×
19

20
        // common execution for orm
21

22
        // Create the gorm database connection with fake db
NEW
23
        fakeGDB, err := gorm.Open(postgres.New(postgres.Config{
×
NEW
24
                Conn: fakeDB,
×
NEW
25
        }), &gorm.Config{
×
NEW
26
                SkipDefaultTransaction: true,
×
NEW
27
        })
×
NEW
28
        if err != nil {
×
NEW
29
                return nil, nil, err
×
NEW
30
        }
×
31

NEW
32
        return fakeGDB, sqlMock, nil
×
33
}
34

35
// CloseDB close the gorm database connection
NEW
36
func CloseDB(t *testing.T, gdb *gorm.DB) {
×
NEW
37
        db, err := gdb.DB()
×
NEW
38
        require.NoError(t, err)
×
NEW
39
        require.NoError(t, db.Close())
×
NEW
40
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc