blob: bad31d126dacc4f939a9189dedc66fdd5dd6a10c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package processor
import (
"context"
"time"
"github.com/jmoiron/sqlx"
)
//go:generate mockgen -source=$GOFILE -package=$GOPACKAGE -destination=mock_$GOFILE
type DB interface {
TestInsert(ctx context.Context, message string) error
}
type DBImpl struct {
db *sqlx.DB
}
var _ DB = (*DBImpl)(nil)
func NewDB(db *sqlx.DB) DB {
return &DBImpl{db: db}
}
func (db DBImpl) TestInsert(ctx context.Context, message string) error {
_, err := db.db.ExecContext(ctx, "INSERT INTO test (created_at, test) VALUES ($1, $2)", time.Now(), message)
return err
}
|