H-130: reject empty rollback migration path (#21)
* H-130: reject empty rollback migration path * H-130: lock Captain inbox assistant uniqueness --------- Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -116,6 +116,10 @@ func MigrateSteps(dbURL string, migrationsPath string, steps int) error {
|
||||
|
||||
// RollbackMigrations rolls back all migrations (drops all tables).
|
||||
func RollbackMigrations(dbURL string, migrationsPath string) error {
|
||||
if migrationsPath == "" {
|
||||
return errors.New("migrations path is required")
|
||||
}
|
||||
|
||||
m, err := migrate.New(
|
||||
fmt.Sprintf("file://%s", migrationsPath),
|
||||
dbURL,
|
||||
|
||||
@@ -34,6 +34,17 @@ func TestCaptainInboxRepo_Create(t *testing.T) {
|
||||
assert.Equal(t, uint(100), ci.AccountID)
|
||||
}
|
||||
|
||||
func TestCaptainInboxRepo_Create_OnlyOneActiveAssistantPerInbox(t *testing.T) {
|
||||
db := setupTestDB(t, &model.CaptainInbox{})
|
||||
repo := NewCaptainInboxRepo(db)
|
||||
ctx := context.Background()
|
||||
|
||||
require.NoError(t, repo.Create(ctx, newTestCaptainInbox(1, 10, 100)))
|
||||
require.Error(t, repo.Create(ctx, newTestCaptainInbox(2, 10, 100)))
|
||||
require.NoError(t, repo.Delete(ctx, 1, 10))
|
||||
require.NoError(t, repo.Create(ctx, newTestCaptainInbox(2, 10, 100)))
|
||||
}
|
||||
|
||||
// ========== Delete ==========
|
||||
|
||||
func TestCaptainInboxRepo_Delete(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user