Unverified Commit 4b9efedf authored by Brice Rising's avatar Brice Rising Committed by Matt Farina
Browse files

Skip inaccessible file tests for root


Root can access all files, so the tests for inaccessible files were failing. Now we will skip these tests when running as root.

Signed-off-by: default avatarBrice Rising <brice.rising@slalom.com>
(cherry picked from commit 3469c9a1)
No related merge requests found
Showing with 45 additions and 0 deletions
+45 -0
......@@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"os/user"
"path/filepath"
"runtime"
"testing"
......@@ -147,6 +148,13 @@ func TestCopyDirFail_SrcInaccessible(t *testing.T) {
t.Skip("skipping on windows")
}
var current_user, err = user.Current()
if current_user.Name == "root" {
// Skipping if root, because all files are accessible
t.Skip("Skipping for root user")
}
var srcdir, dstdir string
cleanup := setupInaccessibleDir(t, func(dir string) error {
......@@ -175,6 +183,13 @@ func TestCopyDirFail_DstInaccessible(t *testing.T) {
t.Skip("skipping on windows")
}
var current_user, err = user.Current()
if current_user.Name == "root" {
// Skipping if root, because all files are accessible
t.Skip("Skipping for root user")
}
var srcdir, dstdir string
dir, err := ioutil.TempDir("", "helm-tmp")
......@@ -264,6 +279,13 @@ func TestCopyDirFailOpen(t *testing.T) {
t.Skip("skipping on windows")
}
var current_user, err = user.Current()
if current_user.Name == "root" {
// Skipping if root, because all files are accessible
t.Skip("Skipping for root user")
}
var srcdir, dstdir string
dir, err := ioutil.TempDir("", "helm-tmp")
......@@ -422,6 +444,13 @@ func TestCopyFileFail(t *testing.T) {
t.Skip("skipping on windows")
}
var current_user, err = user.Current()
if current_user.Name == "root" {
// Skipping if root, because all files are accessible
t.Skip("Skipping for root user")
}
dir, err := ioutil.TempDir("", "helm-tmp")
if err != nil {
t.Fatal(err)
......@@ -501,6 +530,14 @@ func setupInaccessibleDir(t *testing.T, op func(dir string) error) func() {
}
func TestIsDir(t *testing.T) {
var current_user, err = user.Current()
if current_user.Name == "root" {
// Skipping if root, because all files are accessible
t.Skip("Skipping for root user")
}
wd, err := os.Getwd()
if err != nil {
t.Fatal(err)
......@@ -546,6 +583,14 @@ func TestIsDir(t *testing.T) {
}
func TestIsSymlink(t *testing.T) {
var current_user, err = user.Current()
if current_user.Name == "root" {
// Skipping if root, because all files are accessible
t.Skip("Skipping for root user")
}
dir, err := ioutil.TempDir("", "helm-tmp")
if err != nil {
t.Fatal(err)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment