chore: Remove unused function

This commit is contained in:
SoXX 2024-08-13 15:41:55 +02:00
parent b7e3877b68
commit de28bdbb0b

View File

@ -3,12 +3,8 @@ package test
import (
"context"
"database/sql"
"net/url"
"strconv"
"strings"
"time"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
migrate "github.com/rubenv/sql-migrate"
postgrescontainer "github.com/testcontainers/testcontainers-go/modules/postgres"
"gorm.io/driver/postgres"
@ -84,41 +80,3 @@ func getGormDB(connectionString string) (*gorm.DB, error) {
TranslateError: true,
})
}
func DatabaseModesFromConnectionString(ctx context.Context, pgContainer *postgrescontainer.PostgresContainer) (*models.DatabaseConfig, error) {
var err error
connectionString, err := pgContainer.ConnectionString(ctx)
if err != nil {
return nil, err
}
connectionStringUrl, err := url.Parse(connectionString)
if err != nil {
return nil, err
}
split := strings.Split(connectionStringUrl.Host, ":")
host := split[0]
port, err := strconv.Atoi(split[1])
if err != nil {
return nil, err
}
database := strings.TrimPrefix(connectionStringUrl.Path, "/")
username := connectionStringUrl.User.Username()
password, _ := connectionStringUrl.User.Password()
return &models.DatabaseConfig{
Endpoint: host,
Username: username,
Password: password,
Database: database,
Port: port,
SSL: false,
Timezone: "Europe/Berlin",
Debug: true,
}, nil
}