3
0
mirror of https://kolaente.dev/konrad/docker-db-backup.git synced 2026-01-11 08:20:07 +01:00

feat: add support for different postgres versions

This commit is contained in:
kolaente
2021-12-05 12:11:50 +01:00
parent 80d1b33d00
commit c5f0b46e77
2 changed files with 40 additions and 1 deletions

View File

@@ -115,3 +115,28 @@ func TestPostgresDumper_buildConnStr(t *testing.T) {
})
}
}
func TestFindPGVersionFromEnv(t *testing.T) {
t.Run("no PG_MAJOR", func(t *testing.T) {
pgVersion := findPgVersion([]string{})
if pgVersion != "" {
t.Errorf("Version is not empty")
}
})
t.Run("pg 14", func(t *testing.T) {
pgVersion := findPgVersion([]string{
"POSTGRES_PASSWORD=test",
"POSTGRES_USER=user",
"POSTGRES_DB=test",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/14/bin",
"GOSU_VERSION=1.14",
"LANG=en_US.utf8",
"PG_MAJOR=14",
"PG_VERSION=14.1-1.pgdg110+1",
"PGDATA=/var/lib/postgresql/data",
})
if pgVersion != "14" {
t.Errorf("Version is not 14")
}
})
}