From 8386f6cadfc3d9fd4b32f43d3fee31e2e0b4cf93 Mon Sep 17 00:00:00 2001 From: machine424 Date: Fri, 20 Dec 2024 16:46:36 +0100 Subject: [PATCH] debug --- cmd/thanos/tools_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/cmd/thanos/tools_test.go b/cmd/thanos/tools_test.go index 7d39abda55..e7d81ae53f 100644 --- a/cmd/thanos/tools_test.go +++ b/cmd/thanos/tools_test.go @@ -4,6 +4,7 @@ package main import ( + "fmt" "os" "testing" @@ -49,6 +50,39 @@ func Test_CheckRules_Glob(t *testing.T) { // Unreadble path files = &[]string{"./testdata/rules-files/unreadable_valid.yaml"} filename := (*files)[0] + // TODO: debugging + + info, _ := os.Stat("./testdata/rules-files/unreadable_valid.yaml") + fmt.Printf("XXX perm: %04o\n", info.Mode().Perm()) + + info, _ = os.Stat("./testdata/rules-files") + fmt.Printf("XXX perm: %04o\n", info.Mode().Perm()) + + info, _ = os.Stat("./") + fmt.Printf("XXX perm: %04o\n", info.Mode().Perm()) + + err := os.Chmod(filename, 0000) + if err != nil { + fmt.Println("XXX 0000", err) + } + err = os.Chmod(filename, 0777) + if err != nil { + fmt.Println("XXX 0777", err) + } + + info, _ = os.Stat("./testdata/rules-files/unreadable_valid.yaml") + fmt.Printf("XXX perm: %04o\n", info.Mode().Perm()) + + info, _ = os.Stat("./testdata/rules-files") + fmt.Printf("XXX perm: %04o\n", info.Mode().Perm()) + + info, _ = os.Stat("./") + fmt.Printf("XXX perm: %04o\n", info.Mode().Perm()) + + + // solution + + testutil.Ok(t, os.Chmod(filename, 0000), "failed to change file permissions of %s to 0000", 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)