Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
test executor api
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Aug 21, 2018
1 parent 4cf76d7 commit 0860547
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions pkg/storage/executor/api_test.go
@@ -0,0 +1,50 @@
package executor_test

import (
"context"
"database/sql"
"testing"

"github.com/kamilsk/form-api/pkg/storage/executor"
"github.com/stretchr/testify/assert"
)

func TestNew(t *testing.T) {
type contract interface {
Dialect() string

InputReader(context.Context, *sql.Conn) executor.InputReader
InputWriter(context.Context, *sql.Conn) executor.InputWriter
SchemaEditor(context.Context, *sql.Conn) executor.SchemaEditor
SchemaReader(context.Context, *sql.Conn) executor.SchemaReader
TemplateEditor(context.Context, *sql.Conn) executor.TemplateEditor
TemplateReader(context.Context, *sql.Conn) executor.TemplateReader
UserManager(context.Context, *sql.Conn) executor.UserManager
}
t.Run("PostgreSQL", func(t *testing.T) {
assert.NotPanics(t, func() {
var exec contract = executor.New("postgres")
assert.NotEmpty(t, exec.Dialect())
exec.InputReader(nil, nil)
exec.InputWriter(nil, nil)
exec.SchemaEditor(nil, nil)
exec.SchemaReader(nil, nil)
exec.TemplateEditor(nil, nil)
exec.TemplateReader(nil, nil)
exec.UserManager(nil, nil)
})
})
t.Run("MySQL", func(t *testing.T) {
assert.Panics(t, func() {
var exec contract = executor.New("mysql")
assert.NotEmpty(t, exec.Dialect())
exec.InputReader(nil, nil)
exec.InputWriter(nil, nil)
exec.SchemaEditor(nil, nil)
exec.SchemaReader(nil, nil)
exec.TemplateEditor(nil, nil)
exec.TemplateReader(nil, nil)
exec.UserManager(nil, nil)
})
})
}

0 comments on commit 0860547

Please sign in to comment.