refractor: move CopyTo

Will be replaced by os.CopyFS with go 1.23
This commit is contained in:
Alexandre Pujol 2024-10-12 15:40:17 +01:00
parent 982c2c66aa
commit e90ccd214c
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
5 changed files with 9 additions and 53 deletions

View file

@ -8,8 +8,6 @@ import (
"reflect"
"regexp"
"testing"
"github.com/roddhjav/apparmor.d/pkg/paths"
)
func TestDecodeHexInString(t *testing.T) {
@ -90,47 +88,6 @@ func TestRegexReplList_Replace(t *testing.T) {
}
}
func TestCopyTo(t *testing.T) {
tests := []struct {
name string
src *paths.Path
dst *paths.Path
wantErr bool
}{
{
name: "default",
src: paths.New("../../apparmor.d/groups/_full/"),
dst: paths.New("/tmp/test/apparmor.d/groups/_full/"),
wantErr: false,
},
{
name: "issue-source",
src: paths.New("../../apparmor.d/groups/nope/"),
dst: paths.New("/tmp/test/apparmor.d/groups/_full/"),
wantErr: true,
},
// {
// name: "issue-dest-1",
// src: paths.New("../../apparmor.d/groups/_full/"),
// dst: paths.New("/"),
// wantErr: true,
// },
// {
// name: "issue-dest-2",
// src: paths.New("../../apparmor.d/groups/_full/"),
// dst: paths.New("/_full/"),
// wantErr: true,
// },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := CopyTo(tt.src, tt.dst); (err != nil) != tt.wantErr {
t.Errorf("CopyTo() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_Filter(t *testing.T) {
tests := []struct {
name string