mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 22:27:35 +00:00
Use either test or rtest to refer to internal test helpers
A single test file should not use both names.
This commit is contained in:
parent
bfc9c6c971
commit
e01baeabba
@ -6,7 +6,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/test"
|
|
||||||
rtest "github.com/restic/restic/internal/test"
|
rtest "github.com/restic/restic/internal/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ func Test_PrintFunctionsRespectsGlobalStdout(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestReadRepo(t *testing.T) {
|
func TestReadRepo(t *testing.T) {
|
||||||
tempDir := test.TempDir(t)
|
tempDir := rtest.TempDir(t)
|
||||||
|
|
||||||
// test --repo option
|
// test --repo option
|
||||||
var opts GlobalOptions
|
var opts GlobalOptions
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/restic/restic/internal/repository"
|
"github.com/restic/restic/internal/repository"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
"github.com/restic/restic/internal/test"
|
"github.com/restic/restic/internal/test"
|
||||||
rtest "github.com/restic/restic/internal/test"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func openTestRepo(t *testing.T, wrapper backendWrapper) (*repository.Repository, func(), *testEnvironment) {
|
func openTestRepo(t *testing.T, wrapper backendWrapper) (*repository.Repository, func(), *testEnvironment) {
|
||||||
@ -22,14 +21,14 @@ func openTestRepo(t *testing.T, wrapper backendWrapper) (*repository.Repository,
|
|||||||
testRunInit(t, env.gopts)
|
testRunInit(t, env.gopts)
|
||||||
|
|
||||||
repo, err := OpenRepository(context.TODO(), env.gopts)
|
repo, err := OpenRepository(context.TODO(), env.gopts)
|
||||||
rtest.OK(t, err)
|
test.OK(t, err)
|
||||||
return repo, cleanup, env
|
return repo, cleanup, env
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkedLockRepo(ctx context.Context, t *testing.T, repo restic.Repository, env *testEnvironment) (*restic.Lock, context.Context) {
|
func checkedLockRepo(ctx context.Context, t *testing.T, repo restic.Repository, env *testEnvironment) (*restic.Lock, context.Context) {
|
||||||
lock, wrappedCtx, err := lockRepo(ctx, repo, env.gopts.RetryLock, env.gopts.JSON)
|
lock, wrappedCtx, err := lockRepo(ctx, repo, env.gopts.RetryLock, env.gopts.JSON)
|
||||||
rtest.OK(t, err)
|
test.OK(t, err)
|
||||||
rtest.OK(t, wrappedCtx.Err())
|
test.OK(t, wrappedCtx.Err())
|
||||||
if lock.Stale() {
|
if lock.Stale() {
|
||||||
t.Fatal("lock returned stale lock")
|
t.Fatal("lock returned stale lock")
|
||||||
}
|
}
|
||||||
@ -69,7 +68,7 @@ func TestLockUnlockAll(t *testing.T) {
|
|||||||
|
|
||||||
lock, wrappedCtx := checkedLockRepo(context.Background(), t, repo, env)
|
lock, wrappedCtx := checkedLockRepo(context.Background(), t, repo, env)
|
||||||
_, err := unlockAll(0)
|
_, err := unlockAll(0)
|
||||||
rtest.OK(t, err)
|
test.OK(t, err)
|
||||||
if wrappedCtx.Err() == nil {
|
if wrappedCtx.Err() == nil {
|
||||||
t.Fatal("canceled parent context did not cancel context")
|
t.Fatal("canceled parent context did not cancel context")
|
||||||
}
|
}
|
||||||
@ -82,10 +81,10 @@ func TestLockConflict(t *testing.T) {
|
|||||||
repo, cleanup, env := openTestRepo(t, nil)
|
repo, cleanup, env := openTestRepo(t, nil)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
repo2, err := OpenRepository(context.TODO(), env.gopts)
|
repo2, err := OpenRepository(context.TODO(), env.gopts)
|
||||||
rtest.OK(t, err)
|
test.OK(t, err)
|
||||||
|
|
||||||
lock, _, err := lockRepoExclusive(context.Background(), repo, env.gopts.RetryLock, env.gopts.JSON)
|
lock, _, err := lockRepoExclusive(context.Background(), repo, env.gopts.RetryLock, env.gopts.JSON)
|
||||||
rtest.OK(t, err)
|
test.OK(t, err)
|
||||||
defer unlockRepo(lock)
|
defer unlockRepo(lock)
|
||||||
_, _, err = lockRepo(context.Background(), repo2, env.gopts.RetryLock, env.gopts.JSON)
|
_, _, err = lockRepo(context.Background(), repo2, env.gopts.RetryLock, env.gopts.JSON)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
3
internal/cache/file_test.go
vendored
3
internal/cache/file_test.go
vendored
@ -14,7 +14,6 @@ import (
|
|||||||
"github.com/restic/restic/internal/fs"
|
"github.com/restic/restic/internal/fs"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
"github.com/restic/restic/internal/test"
|
"github.com/restic/restic/internal/test"
|
||||||
rtest "github.com/restic/restic/internal/test"
|
|
||||||
|
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
@ -271,7 +270,7 @@ func TestFileSaveConcurrent(t *testing.T) {
|
|||||||
|
|
||||||
func TestFileSaveAfterDamage(t *testing.T) {
|
func TestFileSaveAfterDamage(t *testing.T) {
|
||||||
c := TestNewCache(t)
|
c := TestNewCache(t)
|
||||||
rtest.OK(t, fs.RemoveAll(c.path))
|
test.OK(t, fs.RemoveAll(c.path))
|
||||||
|
|
||||||
// save a few bytes of data in the cache
|
// save a few bytes of data in the cache
|
||||||
data := test.Random(123456789, 42)
|
data := test.Random(123456789, 42)
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"github.com/restic/restic/internal/index"
|
"github.com/restic/restic/internal/index"
|
||||||
"github.com/restic/restic/internal/repository"
|
"github.com/restic/restic/internal/repository"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
"github.com/restic/restic/internal/test"
|
|
||||||
rtest "github.com/restic/restic/internal/test"
|
rtest "github.com/restic/restic/internal/test"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
@ -322,7 +321,7 @@ func TestRepositoryLoadUnpackedRetryBroken(t *testing.T) {
|
|||||||
rtest.OK(t, err)
|
rtest.OK(t, err)
|
||||||
repo, err := repository.New(&damageOnceBackend{Backend: be}, repository.Options{})
|
repo, err := repository.New(&damageOnceBackend{Backend: be}, repository.Options{})
|
||||||
rtest.OK(t, err)
|
rtest.OK(t, err)
|
||||||
err = repo.SearchKey(context.TODO(), test.TestPassword, 10, "")
|
err = repo.SearchKey(context.TODO(), rtest.TestPassword, 10, "")
|
||||||
rtest.OK(t, err)
|
rtest.OK(t, err)
|
||||||
|
|
||||||
rtest.OK(t, repo.LoadIndex(context.TODO()))
|
rtest.OK(t, repo.LoadIndex(context.TODO()))
|
||||||
@ -446,7 +445,7 @@ func buildPackfileWithoutHeader(t testing.TB, blobSizes []int, key *crypto.Key,
|
|||||||
|
|
||||||
var offset uint
|
var offset uint
|
||||||
for i, size := range blobSizes {
|
for i, size := range blobSizes {
|
||||||
plaintext := test.Random(800+i, size)
|
plaintext := rtest.Random(800+i, size)
|
||||||
id := restic.Hash(plaintext)
|
id := restic.Hash(plaintext)
|
||||||
uncompressedLength := uint(0)
|
uncompressedLength := uint(0)
|
||||||
if compress {
|
if compress {
|
||||||
|
Loading…
Reference in New Issue
Block a user