Move errors to new common package, improve test coverage script
This commit is contained in:
parent
404a75862d
commit
2b788b0e9c
4 changed files with 14 additions and 5 deletions
|
@ -1,11 +1,12 @@
|
|||
pushd $(dirname "$0")/.. # run from root dir
|
||||
|
||||
set -e
|
||||
rm -rf ./coverage
|
||||
mkdir ./coverage/
|
||||
|
||||
go build -cover -o target/pilgrim_coverage main.go
|
||||
|
||||
chmod 777 ./target/pilgrim_coverage
|
||||
GOCOVERDIR=coverage ./target/pilgrim
|
||||
GOCOVERDIR=coverage ./target/pilgrim_coverage
|
||||
|
||||
go tool covdata percent -i=coverage
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
package pilgrim_conf
|
||||
package pilgrim_common
|
||||
|
||||
type PilgrimError interface {
|
||||
error
|
||||
}
|
||||
|
||||
type pilgrimValidationError struct {
|
||||
validationError string
|
|
@ -2,6 +2,8 @@ package pilgrim_conf
|
|||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"mvvasilev.dev/pilgrim/internal/pilgrim_common"
|
||||
)
|
||||
|
||||
const DefaultMigrationDirectory = "./migrations"
|
||||
|
@ -143,7 +145,7 @@ func determineMigrationPhaseAndScript(cli MigrationPhaseRetriever) (phase Migrat
|
|||
_, isDownProvided := cli.IsDown()
|
||||
|
||||
if (!isUpProvided && !isDownProvided) || (isUpProvided && isDownProvided) {
|
||||
return MigrationPhase_Down, EmptyString, PilgrimInvalidError("Must provide either --up or --down, but not both.")
|
||||
return MigrationPhase_Down, EmptyString, pilgrim_common.PilgrimInvalidError("Must provide either --up or --down, but not both.")
|
||||
}
|
||||
|
||||
if isUp {
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"mvvasilev.dev/pilgrim/internal/pilgrim_common"
|
||||
)
|
||||
|
||||
const EmptyString = ""
|
||||
|
@ -135,7 +137,7 @@ func ParseArguments(arguments string) map[string]string {
|
|||
// Returns true if valid, with nil error, or false if invalid, with the validation error
|
||||
func (urlParts *UrlParts) Validate() (bool, error) {
|
||||
if !slices.Contains(AvailableDbDrivers, DbDriver(urlParts.Driver)) {
|
||||
return false, PilgrimInvalidError(fmt.Sprintf("URLParts invalid: Provided driver %v is not currently supported ( must be one of %v )", urlParts.Driver, AvailableDbDrivers))
|
||||
return false, pilgrim_common.PilgrimInvalidError(fmt.Sprintf("URLParts invalid: Provided driver \"%v\" is not currently supported ( must be one of %v )", urlParts.Driver, AvailableDbDrivers))
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
|
Loading…
Add table
Reference in a new issue