mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
for sure fixed integration tests, and moved validation check
This commit is contained in:
parent
cd13416614
commit
08e702264b
6 changed files with 5 additions and 36 deletions
|
|
@ -7,7 +7,6 @@ import (
|
|||
"sort"
|
||||
"time"
|
||||
|
||||
pilosa "github.com/featurebasedb/featurebase/v3"
|
||||
"github.com/featurebasedb/featurebase/v3/dax"
|
||||
"github.com/featurebasedb/featurebase/v3/dax/computer"
|
||||
"github.com/featurebasedb/featurebase/v3/dax/controller/poller"
|
||||
|
|
@ -624,11 +623,6 @@ func (c *Controller) translateWorkersToAssignedNodes(tx dax.Transaction, workers
|
|||
|
||||
// CreateDatabase adds a database to the schemar.
|
||||
func (c *Controller) CreateDatabase(ctx context.Context, qdb *dax.QualifiedDatabase) error {
|
||||
// Sanitizing database name
|
||||
if err := pilosa.ValidateName(string(qdb.Name)); err != nil {
|
||||
return errors.Errorf("error with creating database, database name invalid: %v", err)
|
||||
}
|
||||
|
||||
// Create Database ID.
|
||||
if _, err := qdb.CreateID(); err != nil {
|
||||
return errors.Wrap(err, "creating database ID")
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func NewErrDatabaseIDInvalid(databaseID dax.DatabaseID) error {
|
|||
func NewErrDatabaseNameInvalid(databaseName dax.DatabaseName) error {
|
||||
return errors.New(
|
||||
ErrCodeDatabaseNameInvalid,
|
||||
fmt.Sprintf("invalid index or field name %s, must match [a-z][a-z0-9Θ_-]* and contain at most 300 characters", databaseName),
|
||||
fmt.Sprintf("invalid database name %s", databaseName),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
featurebase "github.com/featurebasedb/featurebase/v3"
|
||||
"github.com/featurebasedb/featurebase/v3/dax"
|
||||
"github.com/featurebasedb/featurebase/v3/dax/controller/schemar"
|
||||
"github.com/featurebasedb/featurebase/v3/dax/models"
|
||||
|
|
@ -34,8 +35,8 @@ func (s *Schemar) CreateDatabase(tx dax.Transaction, qdb *dax.QualifiedDatabase)
|
|||
return schemar.NewErrDatabaseIDInvalid(qdb.ID)
|
||||
}
|
||||
|
||||
// Ensure the database name is not blank.
|
||||
if qdb.Name == "" {
|
||||
// Sanitizing database name
|
||||
if err := featurebase.ValidateName(string(qdb.Name)); err != nil {
|
||||
return schemar.NewErrDatabaseNameInvalid(qdb.Name)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ const (
|
|||
ErrDatabaseIDDoesNotExist errors.Code = "DatabaseIDDoesNotExist"
|
||||
ErrDatabaseNameDoesNotExist errors.Code = "DatabaseNameDoesNotExist"
|
||||
ErrDatabaseNameExists errors.Code = "DatabaseNameExists"
|
||||
ErrDatabaseNameInvalid errors.Code = "DatabaseNameInvalid"
|
||||
|
||||
ErrTableIDExists errors.Code = "TableIDExists"
|
||||
ErrTableKeyExists errors.Code = "TableKeyExists"
|
||||
|
|
@ -40,13 +39,6 @@ func NewErrOrganizationIDDoesNotExist(orgID OrganizationID) error {
|
|||
)
|
||||
}
|
||||
|
||||
func NewErrDatabaseNameInvalid(qdb QualifiedDatabase) error {
|
||||
return errors.New(
|
||||
ErrDatabaseNameInvalid,
|
||||
fmt.Sprintf("invalid database name %s, must match [a-z][a-z0-9Θ_-]* and contain at most 300 characters", string(qdb.Name)),
|
||||
)
|
||||
}
|
||||
|
||||
func NewErrDatabaseIDExists(qdbid QualifiedDatabaseID) error {
|
||||
return errors.New(
|
||||
ErrDatabaseIDExists,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ func TestDAXIntegration(t *testing.T) {
|
|||
dbID := dax.DatabaseID("db1")
|
||||
qdbid := dax.NewQualifiedDatabaseID(orgID, dbID)
|
||||
dbname := dax.DatabaseName("dbname1")
|
||||
dbname2 := dax.DatabaseName("-dbname2")
|
||||
qdb := &dax.QualifiedDatabase{
|
||||
OrganizationID: qdbid.OrganizationID,
|
||||
Database: dax.Database{
|
||||
|
|
@ -51,18 +50,6 @@ func TestDAXIntegration(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
qdb2 := &dax.QualifiedDatabase{
|
||||
OrganizationID: qdbid.OrganizationID,
|
||||
Database: dax.Database{
|
||||
ID: qdbid.DatabaseID,
|
||||
Name: dbname2,
|
||||
Options: dax.DatabaseOptions{
|
||||
WorkersMin: 1,
|
||||
WorkersMax: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
t.Run("ServiceStart", func(t *testing.T) {
|
||||
t.Run("AllServicesByDefault", func(t *testing.T) {
|
||||
// Run ManagedCommand with no options (just defaulting to one
|
||||
|
|
@ -817,11 +804,6 @@ func TestDAXIntegration(t *testing.T) {
|
|||
assertCode(t, err, schemar.ErrCodeDatabaseNameInvalid)
|
||||
})
|
||||
|
||||
t.Run("CreateDatabase with Invalid Name", func(t *testing.T) {
|
||||
err := client.CreateDatabase(ctx, qdb2)
|
||||
assertCode(t, err, dax.ErrDatabaseNameInvalid)
|
||||
})
|
||||
|
||||
t.Run("DropDatabase", func(t *testing.T) {
|
||||
err := client.DropDatabase(ctx, qdbid)
|
||||
assertCode(t, err, dax.ErrDatabaseIDDoesNotExist)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ var (
|
|||
ErrInvalidView = errors.New("invalid view")
|
||||
ErrInvalidCacheType = errors.New("invalid cache type")
|
||||
|
||||
ErrName = errors.New("invalid index or field name, must match [a-z][a-z0-9Θ_-]* and contain at most 230 characters")
|
||||
ErrName = errors.New("invalid index or field name, must match [a-z][a-z0-9Θ_-]* and contain at most 300 characters")
|
||||
|
||||
// ErrFragmentNotFound is returned when a fragment does not exist.
|
||||
ErrFragmentNotFound = errors.New("fragment not found")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue