From a90077e38664c6372608e8c489d9d95781c70973 Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Wed, 9 Aug 2017 06:55:32 +0300 Subject: [PATCH] Correctly working in Docker container without OVERRIDE_HOME variable set (fixes #71) --- Dockerfile | 1 + selenoid/base.go | 7 +------ selenoid/docker_test.go | 2 ++ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index dc8f6cf..0a07bd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,5 @@ FROM alpine:3.5 RUN apk add -U ca-certificates tzdata && rm -Rf /var/cache/apk/* COPY cm / +WORKDIR /root ENTRYPOINT ["/cm"] diff --git a/selenoid/base.go b/selenoid/base.go index 15a269d..d7e9bed 100644 --- a/selenoid/base.go +++ b/selenoid/base.go @@ -92,12 +92,7 @@ func getHomeDir() string { } func joinPaths(baseDir string, elem []string) string { - var p string - if baseDir == "" { - p = filepath.Join(elem...) - } else { - p = filepath.Join(append([]string{baseDir}, elem...)...) - } + p := filepath.Join(append([]string{baseDir}, elem...)...) ap, _ := filepath.Abs(p) return ap } diff --git a/selenoid/docker_test.go b/selenoid/docker_test.go index badfba9..6a476a6 100644 --- a/selenoid/docker_test.go +++ b/selenoid/docker_test.go @@ -380,6 +380,8 @@ func TestFilterOutLatest(t *testing.T) { } func TestChooseVolumeConfigDir(t *testing.T) { + dirWithoutVariable := chooseVolumeConfigDir("/some/dir", []string{"one", "two"}) + AssertThat(t, dirWithoutVariable, EqualTo{"/some/dir"}) os.Setenv("OVERRIDE_HOME", "/test/dir") defer os.Unsetenv("OVERRIDE_HOME") dir := chooseVolumeConfigDir("/some/dir", []string{"one", "two"})