CI: Update test.sh script and config_filepaths_test.go

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2022-07-22 14:58:20 +02:00
parent 0b46643def
commit 3b2f53da07
2 changed files with 27 additions and 38 deletions

View file

@ -1,13 +1,9 @@
package config
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/photoprism/photoprism/pkg/fs"
"github.com/photoprism/photoprism/pkg/rnd"
"github.com/stretchr/testify/assert"
)
@ -343,30 +339,7 @@ func TestConfig_OriginalsDeletable(t *testing.T) {
c.Settings().Features.Delete = true
c.options.ReadOnly = false
t.Logf("(1) RO: %t, Writable: %t, Delete: %t", c.ReadOnly(), fs.Writable(c.OriginalsPath()), c.Settings().Features.Delete)
assert.True(t, c.OriginalsDeletable())
testDir, err := filepath.Abs("testdata/readonly")
if err != nil {
t.Fatal(err)
}
if err = os.MkdirAll(testDir, os.ModeDir); err != nil {
t.Fatal(err)
}
defer func(testDir string) {
_ = os.Chmod(testDir, os.ModePerm)
_ = os.Remove(testDir)
}(testDir)
c.options.OriginalsPath = testDir
t.Logf("(2) RO: %t, Writable: %t, Delete: %t", c.ReadOnly(), fs.Writable(c.OriginalsPath()), c.Settings().Features.Delete)
assert.False(t, c.OriginalsDeletable())
}
func TestConfig_ImportPath2(t *testing.T) {

View file

@ -1,15 +1,31 @@
#!/usr/bin/env bash
# exit on error
set -ex
# Login
# Login to Docker Hub.
scripts/docker/login.sh
# Run tests
docker-compose -f docker-compose.ci.yml down --remove-orphans
docker-compose -f docker-compose.ci.yml pull
docker-compose -f docker-compose.ci.yml build --pull
trap "docker-compose -f docker-compose.ci.yml down --remove-orphans" INT TERM
docker-compose -f docker-compose.ci.yml run --rm photoprism make all test install migrate
docker-compose -f docker-compose.ci.yml down --remove-orphans
# Define functions.
cleanUp() {
COMPOSE_PROJECT_NAME=ci docker-compose -f docker-compose.ci.yml down --remove-orphans
}
# Make sure containers are not running and don't keep running.
cleanUp
trap cleanUp INT
# Set up environment and run tests.
ERROR=0
COMPOSE_PROJECT_NAME=ci docker-compose -f docker-compose.ci.yml pull --ignore-pull-failures && \
COMPOSE_PROJECT_NAME=ci docker-compose -f docker-compose.ci.yml build --pull && \
COMPOSE_PROJECT_NAME=ci docker-compose -f docker-compose.ci.yml run --rm photoprism make all test install migrate || \
ERROR=1
# Stop containers.
cleanUp
# Failed?
if [[ $ERROR == "1" ]]; then
echo "Failed."
exit 1
fi
echo "Done."