mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 23:06:32 +00:00
restorer: windows test fixes
This commit is contained in:
parent
ca41c8fd11
commit
9572b7224f
@ -6,18 +6,30 @@ package restic
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
rtest "github.com/restic/restic/internal/test"
|
rtest "github.com/restic/restic/internal/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setAndVerifyXattr(t *testing.T, file string, attrs []ExtendedAttribute) {
|
func setAndVerifyXattr(t *testing.T, file string, attrs []ExtendedAttribute) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
// windows seems to convert the xattr name to upper case
|
||||||
|
for i := range attrs {
|
||||||
|
attrs[i].Name = strings.ToUpper(attrs[i].Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
node := Node{
|
node := Node{
|
||||||
|
Type: "file",
|
||||||
ExtendedAttributes: attrs,
|
ExtendedAttributes: attrs,
|
||||||
}
|
}
|
||||||
rtest.OK(t, node.restoreExtendedAttributes(file))
|
rtest.OK(t, node.restoreExtendedAttributes(file))
|
||||||
|
|
||||||
nodeActual := Node{}
|
nodeActual := Node{
|
||||||
|
Type: "file",
|
||||||
|
}
|
||||||
rtest.OK(t, nodeActual.fillExtendedAttributes(file, false))
|
rtest.OK(t, nodeActual.fillExtendedAttributes(file, false))
|
||||||
|
|
||||||
rtest.Assert(t, nodeActual.sameExtendedAttributes(node), "xattr mismatch got %v expected %v", nodeActual.ExtendedAttributes, node.ExtendedAttributes)
|
rtest.Assert(t, nodeActual.sameExtendedAttributes(node), "xattr mismatch got %v expected %v", nodeActual.ExtendedAttributes, node.ExtendedAttributes)
|
||||||
|
10
internal/restorer/fileswriter_other_test.go
Normal file
10
internal/restorer/fileswriter_other_test.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
//go:build !windows
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package restorer
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func notEmptyDirError() error {
|
||||||
|
return syscall.ENOTEMPTY
|
||||||
|
}
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"syscall"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/errors"
|
"github.com/restic/restic/internal/errors"
|
||||||
@ -72,7 +72,7 @@ func TestCreateFile(t *testing.T) {
|
|||||||
rtest.OK(t, os.Mkdir(path, 0o700))
|
rtest.OK(t, os.Mkdir(path, 0o700))
|
||||||
rtest.OK(t, os.WriteFile(filepath.Join(path, "file"), []byte("data"), 0o400))
|
rtest.OK(t, os.WriteFile(filepath.Join(path, "file"), []byte("data"), 0o400))
|
||||||
},
|
},
|
||||||
err: syscall.ENOTEMPTY,
|
err: notEmptyDirError(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "hardlinks",
|
name: "hardlinks",
|
||||||
@ -81,6 +81,11 @@ func TestCreateFile(t *testing.T) {
|
|||||||
rtest.OK(t, os.Link(path, path+"h"))
|
rtest.OK(t, os.Link(path, path+"h"))
|
||||||
},
|
},
|
||||||
check: func(t testing.TB, path string) {
|
check: func(t testing.TB, path string) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
// hardlinks are not supported on windows
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
data, err := os.ReadFile(path + "h")
|
data, err := os.ReadFile(path + "h")
|
||||||
rtest.OK(t, err)
|
rtest.OK(t, err)
|
||||||
rtest.Equals(t, "test-test-test-data", string(data), "unexpected content change")
|
rtest.Equals(t, "test-test-test-data", string(data), "unexpected content change")
|
||||||
|
7
internal/restorer/fileswriter_windows_test.go
Normal file
7
internal/restorer/fileswriter_windows_test.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package restorer
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func notEmptyDirError() error {
|
||||||
|
return syscall.ERROR_DIR_NOT_EMPTY
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user