Ejemplo n.º 1
0
func New(driver, source string, logger webfw.Logger) (r content.Repo, err error) {
	switch driver {
	case "sqlite3", "postgres":
		db := db.New(logger)
		if err = db.Open(driver, source); err != nil {
			err = fmt.Errorf("Error connecting to database: %v", err)
			return
		}

		switch driver {
		case "postgres":
			r = postgres.NewRepo(db, logger)
		case "sqlite3":
			r = sqlite3.NewRepo(db, logger)
		}

		return
	default:
		panic(fmt.Sprintf("Cannot provide a repo for driver '%s'\n", driver))
	}
}
Ejemplo n.º 2
0
package test

import (
	"os"
	"testing"

	dbo "github.com/urandom/readeef/content/sql/db"
	"github.com/urandom/readeef/content/sql/sqlite3"
	"github.com/urandom/readeef/tests"
	"github.com/urandom/webfw"
)

func TestRepo(t *testing.T) {
	tests.CheckBool(t, false, repo.HasErr())
}

var (
	logger = webfw.NewStandardLogger(os.Stderr, "", 0)
	db     = dbo.New(logger)
	repo   = sqlite3.NewRepo(db, logger)
)