test(config): skip permission test when running as root
ci / vet, staticcheck, test, build (push) Successful in 1m58s
ci / vet, staticcheck, test, build (push) Successful in 1m58s
The Gitea CI runner executes as root, which bypasses filesystem permission checks. The TestLoad_ReadError test creates a mode-0000 file and expects a read error, but root can always read files regardless of mode. Skip the test under root instead of removing it so it still runs in restricted environments. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -103,6 +103,9 @@ func TestLoad_StopsAtGitRoot(t *testing.T) {
|
|||||||
// TestLoad_ReadError covers the !os.IsNotExist(err) branch (config.go:59-61)
|
// TestLoad_ReadError covers the !os.IsNotExist(err) branch (config.go:59-61)
|
||||||
// when the file exists but is not readable.
|
// when the file exists but is not readable.
|
||||||
func TestLoad_ReadError(t *testing.T) {
|
func TestLoad_ReadError(t *testing.T) {
|
||||||
|
if os.Getuid() == 0 {
|
||||||
|
t.Skip("skipping: root bypasses file permission checks")
|
||||||
|
}
|
||||||
tmp := t.TempDir()
|
tmp := t.TempDir()
|
||||||
cfgPath := filepath.Join(tmp, Filename)
|
cfgPath := filepath.Join(tmp, Filename)
|
||||||
if err := os.WriteFile(cfgPath, []byte("ignore: []"), 0o000); err != nil {
|
if err := os.WriteFile(cfgPath, []byte("ignore: []"), 0o000); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user