Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
107 lines
2.2 KiB
Go
107 lines
2.2 KiB
Go
package tests
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/cortezaproject/corteza/server/pkg/cli"
|
|
"github.com/cortezaproject/corteza/server/pkg/id"
|
|
"github.com/cortezaproject/corteza/server/store"
|
|
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/mssql"
|
|
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/mysql"
|
|
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/postgres"
|
|
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers/sqlite"
|
|
"github.com/cortezaproject/corteza/server/tests/helpers"
|
|
_ "github.com/joho/godotenv/autoload"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
var (
|
|
now = func() *time.Time {
|
|
n := time.Now().Round(time.Second)
|
|
return &n
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
helpers.RecursiveDotEnvLoad()
|
|
id.Init(cli.Context())
|
|
}
|
|
|
|
func Test_RDBMS_SQLITE(t *testing.T) {
|
|
testAllGenerated(t, setup(t, sqlite.Connect))
|
|
}
|
|
|
|
func Test_RDBMS_MYSQL(t *testing.T) {
|
|
testAllGenerated(t, setup(t, mysql.Connect))
|
|
}
|
|
|
|
func Test_RDBMS_SQLSERVER_2022(t *testing.T) {
|
|
testAllGenerated(t, setup(t, mssql.Connect))
|
|
}
|
|
|
|
func Test_RDBMS_SQLSERVER_2019(t *testing.T) {
|
|
testAllGenerated(t, setup(t, mssql.Connect))
|
|
}
|
|
|
|
func Test_RDBMS_SQLSERVER_2017(t *testing.T) {
|
|
testAllGenerated(t, setup(t, mssql.Connect))
|
|
}
|
|
|
|
func Test_RDBMS_PGSQL(t *testing.T) {
|
|
testAllGenerated(t, setup(t, postgres.Connect))
|
|
}
|
|
|
|
func Test_RDBMS_COCKROACHDB(t *testing.T) {
|
|
testAllGenerated(t, setup(t, nil))
|
|
}
|
|
|
|
func Test_MEMORY(t *testing.T) {
|
|
testAllGenerated(t, setup(t, nil))
|
|
}
|
|
|
|
func Test_MONGODB(t *testing.T) {
|
|
testAllGenerated(t, setup(t, nil))
|
|
}
|
|
|
|
func Test_ELASTICSEARCH(t *testing.T) {
|
|
testAllGenerated(t, setup(t, nil))
|
|
}
|
|
|
|
func setup(t *testing.T, connect store.ConnectorFn) (s store.Storer) {
|
|
t.Parallel()
|
|
|
|
if connect == nil {
|
|
t.Skipf("connection function not set, skipping tests")
|
|
return
|
|
}
|
|
|
|
var (
|
|
err error
|
|
env = t.Name()[5:] + "_DSN"
|
|
dsn, has = os.LookupEnv(env)
|
|
ctx = context.Background()
|
|
)
|
|
|
|
if !has || len(dsn) == 0 {
|
|
t.Skipf("no %s found, skipping tests", env)
|
|
return
|
|
}
|
|
|
|
s, err = connect(ctx, dsn)
|
|
if err != nil {
|
|
t.Errorf("failed to initialize: %v", err)
|
|
return
|
|
}
|
|
|
|
err = store.Upgrade(ctx, zap.NewNop(), s)
|
|
if err != nil {
|
|
t.Fatalf("failed to upgrade : %v", err)
|
|
return
|
|
}
|
|
|
|
return s
|
|
}
|