mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-04 11:25:52 +08:00

* fix: support multitenancy in org * fix: register and login working now * fix: changes to migration * fix: migrations run both on sqlite and postgres * fix: remove user flags from fe and be * fix: remove ingestion keys from update * fix: multitenancy support for apdex settings * fix: render ts for users correctly * fix: fix migration to run for new tenants * fix: clean up migrations * fix: address comments * Update pkg/sqlmigration/013_update_organization.go Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: fix build * fix: force invites with org id * Update pkg/query-service/auth/auth.go Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: address comments * fix: address comments * fix: provier with their own dialect * fix: update dialects * fix: remove unwanted change * Update pkg/query-service/app/http_handler.go Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: different files for types --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
77 lines
1.5 KiB
Go
77 lines
1.5 KiB
Go
package sqlstoretest
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"fmt"
|
|
|
|
"github.com/DATA-DOG/go-sqlmock"
|
|
"github.com/jmoiron/sqlx"
|
|
"github.com/uptrace/bun"
|
|
"github.com/uptrace/bun/dialect/sqlitedialect"
|
|
"go.signoz.io/signoz/pkg/sqlstore"
|
|
)
|
|
|
|
var _ sqlstore.SQLStore = (*Provider)(nil)
|
|
|
|
type Provider struct {
|
|
db *sql.DB
|
|
mock sqlmock.Sqlmock
|
|
bunDB *bun.DB
|
|
sqlxDB *sqlx.DB
|
|
dialect *TestDialect
|
|
}
|
|
|
|
func New(config sqlstore.Config, matcher sqlmock.QueryMatcher) *Provider {
|
|
db, mock, err := sqlmock.New(sqlmock.QueryMatcherOption(matcher))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
var bunDB *bun.DB
|
|
var sqlxDB *sqlx.DB
|
|
|
|
if config.Provider == "sqlite" {
|
|
bunDB = bun.NewDB(db, sqlitedialect.New())
|
|
sqlxDB = sqlx.NewDb(db, "sqlite3")
|
|
} else {
|
|
panic(fmt.Errorf("provider %q is not supported by mockSQLStore", config.Provider))
|
|
}
|
|
|
|
return &Provider{
|
|
db: db,
|
|
mock: mock,
|
|
bunDB: bunDB,
|
|
sqlxDB: sqlxDB,
|
|
dialect: &TestDialect{},
|
|
}
|
|
}
|
|
|
|
func (provider *Provider) BunDB() *bun.DB {
|
|
return provider.bunDB
|
|
}
|
|
|
|
func (provider *Provider) SQLDB() *sql.DB {
|
|
return provider.db
|
|
}
|
|
|
|
func (provider *Provider) SQLxDB() *sqlx.DB {
|
|
return provider.sqlxDB
|
|
}
|
|
|
|
func (provider *Provider) Mock() sqlmock.Sqlmock {
|
|
return provider.mock
|
|
}
|
|
|
|
func (provider *Provider) Dialect() sqlstore.SQLDialect {
|
|
return provider.dialect
|
|
}
|
|
|
|
func (provider *Provider) BunDBCtx(ctx context.Context) bun.IDB {
|
|
return provider.bunDB
|
|
}
|
|
|
|
func (provider *Provider) RunInTxCtx(ctx context.Context, opts *sql.TxOptions, cb func(ctx context.Context) error) error {
|
|
return cb(ctx)
|
|
}
|