mirror of
https://github.com/databasus/databasus.git
synced 2026-04-06 00:32:03 +02:00
49 lines
982 B
Go
49 lines
982 B
Go
package databases
|
|
|
|
import (
|
|
"postgresus-backend/internal/features/databases/databases/postgresql"
|
|
"postgresus-backend/internal/features/notifiers"
|
|
"postgresus-backend/internal/features/storages"
|
|
"postgresus-backend/internal/util/tools"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func CreateTestDatabase(
|
|
userID uuid.UUID,
|
|
storage *storages.Storage,
|
|
notifier *notifiers.Notifier,
|
|
) *Database {
|
|
database := &Database{
|
|
UserID: userID,
|
|
Name: "test " + uuid.New().String(),
|
|
Type: DatabaseTypePostgres,
|
|
|
|
Postgresql: &postgresql.PostgresqlDatabase{
|
|
Version: tools.PostgresqlVersion16,
|
|
Host: "localhost",
|
|
Port: 5432,
|
|
Username: "postgres",
|
|
Password: "postgres",
|
|
},
|
|
|
|
Notifiers: []notifiers.Notifier{
|
|
*notifier,
|
|
},
|
|
}
|
|
|
|
database, err := databaseRepository.Save(database)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return database
|
|
}
|
|
|
|
func RemoveTestDatabase(database *Database) {
|
|
err := databaseRepository.Delete(database.ID)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|