mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 19:08:55 +00:00
ff7ef5007e
The ioutil functions are deprecated since Go 1.17 and only wrap another library function. Thus directly call the underlying function. This commit only mechanically replaces the function calls.
39 lines
832 B
Go
39 lines
832 B
Go
package restorer
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
rtest "github.com/restic/restic/internal/test"
|
|
)
|
|
|
|
func TestFilesWriterBasic(t *testing.T) {
|
|
dir, cleanup := rtest.TempDir(t)
|
|
defer cleanup()
|
|
|
|
w := newFilesWriter(1)
|
|
|
|
f1 := dir + "/f1"
|
|
f2 := dir + "/f2"
|
|
|
|
rtest.OK(t, w.writeToFile(f1, []byte{1}, 0, 2, false))
|
|
rtest.Equals(t, 0, len(w.buckets[0].files))
|
|
|
|
rtest.OK(t, w.writeToFile(f2, []byte{2}, 0, 2, false))
|
|
rtest.Equals(t, 0, len(w.buckets[0].files))
|
|
|
|
rtest.OK(t, w.writeToFile(f1, []byte{1}, 1, -1, false))
|
|
rtest.Equals(t, 0, len(w.buckets[0].files))
|
|
|
|
rtest.OK(t, w.writeToFile(f2, []byte{2}, 1, -1, false))
|
|
rtest.Equals(t, 0, len(w.buckets[0].files))
|
|
|
|
buf, err := os.ReadFile(f1)
|
|
rtest.OK(t, err)
|
|
rtest.Equals(t, []byte{1, 1}, buf)
|
|
|
|
buf, err = os.ReadFile(f2)
|
|
rtest.OK(t, err)
|
|
rtest.Equals(t, []byte{2, 2}, buf)
|
|
}
|