Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(tools_test.go/Test_CheckRules_Glob): take into consideration RO current dirs while changing files permissions. #8014

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cmd/thanos/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main

import (
"os"
"path"
"testing"

"github.com/go-kit/log"
Expand Down Expand Up @@ -47,9 +48,12 @@ func Test_CheckRules_Glob(t *testing.T) {
testutil.NotOk(t, checkRulesFiles(logger, files), "expected err for file %s", files)

// Unreadble path
files = &[]string{"./testdata/rules-files/unreadable_valid.yaml"}
filename := (*files)[0]
testutil.Ok(t, os.Chmod(filename, 0000), "failed to change file permissions of %s to 0000", filename)
// Move the initial file to a temp dir and make it unreadble there, in case the process cannot chmod the file in the current dir.
filename := "./testdata/rules-files/unreadable_valid.yaml"
bytesRead, err := os.ReadFile(filename)
testutil.Ok(t, err)
filename = path.Join(t.TempDir(), "file.yaml")
testutil.Ok(t, os.WriteFile(filename, bytesRead, 0000))
files = &[]string{filename}
testutil.NotOk(t, checkRulesFiles(logger, files), "expected err for file %s", files)
testutil.Ok(t, os.Chmod(filename, 0777), "failed to change file permissions of %s to 0777", filename)
}
Loading