Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
machine424 committed Dec 20, 2024
1 parent cc35bd6 commit 8386f6c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cmd/thanos/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package main

import (
"fmt"
"os"
"testing"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8386f6c

Please sign in to comment.