about summary refs log blame commit diff
path: root/src/payload-processor/processor/db.go
blob: bad31d126dacc4f939a9189dedc66fdd5dd6a10c (plain) (tree)



























                                                                                                                    
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
}