mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
config: fix file/folder ownership
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
58
util/confutil/config_unix_test.go
Normal file
58
util/confutil/config_unix_test.go
Normal file
@ -0,0 +1,58 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package confutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIsSubPath(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
basePath string
|
||||
subPath string
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "SubPath is a direct subdirectory",
|
||||
basePath: "/home/user",
|
||||
subPath: "/home/user/docs",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "SubPath is the same as basePath",
|
||||
basePath: "/home/user",
|
||||
subPath: "/home/user",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "SubPath is not a subdirectory",
|
||||
basePath: "/home/user",
|
||||
subPath: "/home/otheruser",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "SubPath is a nested subdirectory",
|
||||
basePath: "/home/user",
|
||||
subPath: "/home/user/docs/reports",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "SubPath is a sibling directory",
|
||||
basePath: "/home/user",
|
||||
subPath: "/home/user2",
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ok, err := isSubPath(tt.basePath, tt.subPath)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.expected, ok)
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user