Shaman: fail unit test when running as root user (linux) #104234

Manually merged
Sybren A. Stüvel merged 2 commits from michael-2/flamenco:mgr_api_meta_test_TestCheckSharedStoragePath into main 2023-07-07 16:07:17 +02:00
Showing only changes of commit 4deef05cf9 - Show all commits

View File

@ -6,6 +6,7 @@ import (
"io/fs" "io/fs"
"net/http" "net/http"
"os" "os"
"os/user"
"path/filepath" "path/filepath"
"runtime" "runtime"
"testing" "testing"
@ -189,6 +190,11 @@ func TestCheckSharedStoragePath(t *testing.T) {
// that seems consistent. // that seems consistent.
// FIXME: find another way to test with unwritable directories on Windows. // FIXME: find another way to test with unwritable directories on Windows.
if runtime.GOOS != "windows" { if runtime.GOOS != "windows" {
currentUser, err := user.Current()
if err != nil {
t.FailNow()
} else if currentUser.Username != "root" {
parentPath := filepath.Join(mf.tempdir, "deep") parentPath := filepath.Join(mf.tempdir, "deep")
testPath := filepath.Join(parentPath, "nesting") testPath := filepath.Join(parentPath, "nesting")
if err := os.Mkdir(parentPath, fs.ModePerm); !assert.NoError(t, err) { if err := os.Mkdir(parentPath, fs.ModePerm); !assert.NoError(t, err) {
@ -205,6 +211,7 @@ func TestCheckSharedStoragePath(t *testing.T) {
assert.Contains(t, result.Cause, "Unable to create a file") assert.Contains(t, result.Cause, "Unable to create a file")
} }
} }
}
func TestSaveSetupAssistantConfig(t *testing.T) { func TestSaveSetupAssistantConfig(t *testing.T) {
mf, finish := metaTestFixtures(t) mf, finish := metaTestFixtures(t)

Please keep unrelated formatting changes out of a PR. I'll remove this before landing; this is just a request for other/future PRs.

Please keep unrelated formatting changes out of a PR. I'll remove this before landing; this is just a request for other/future PRs.