2021-05-14 20:20:21 +01:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-01-06 19:55:46 +00:00
|
|
|
"storj.io/storj/cmd/uplink/ultest"
|
2021-05-14 20:20:21 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRmRemote(t *testing.T) {
|
2021-06-25 02:55:13 +01:00
|
|
|
t.Run("Basic", func(t *testing.T) {
|
|
|
|
state := ultest.Setup(commands,
|
|
|
|
ultest.WithFile("sj://user/file1.txt"),
|
|
|
|
ultest.WithFile("sj://user/file2.txt"),
|
|
|
|
ultest.WithFile("/home/user/file1.txt"),
|
|
|
|
ultest.WithFile("/home/user/file2.txt"),
|
|
|
|
)
|
2021-05-14 20:20:21 +01:00
|
|
|
|
2021-06-25 02:55:13 +01:00
|
|
|
state.Succeed(t, "rm", "sj://user/file1.txt").RequireFiles(t,
|
|
|
|
ultest.File{Loc: "sj://user/file2.txt"},
|
|
|
|
ultest.File{Loc: "/home/user/file1.txt"},
|
|
|
|
ultest.File{Loc: "/home/user/file2.txt"},
|
|
|
|
)
|
|
|
|
})
|
2021-05-14 20:20:21 +01:00
|
|
|
|
2021-06-25 02:55:13 +01:00
|
|
|
t.Run("Recursive", func(t *testing.T) {
|
|
|
|
state := ultest.Setup(commands,
|
|
|
|
ultest.WithFile("sj://user/files/file1.txt"),
|
|
|
|
ultest.WithFile("sj://user/files/file2.txt"),
|
|
|
|
ultest.WithFile("sj://user/other_file1.txt"),
|
|
|
|
ultest.WithFile("/home/user/files/file1.txt"),
|
|
|
|
ultest.WithFile("/home/user/files/file2.txt"),
|
|
|
|
)
|
2021-05-14 20:20:21 +01:00
|
|
|
|
2021-06-25 02:55:13 +01:00
|
|
|
state.Succeed(t, "rm", "sj://user/files", "-r").RequireFiles(t,
|
|
|
|
ultest.File{Loc: "sj://user/other_file1.txt"},
|
|
|
|
ultest.File{Loc: "/home/user/files/file1.txt"},
|
|
|
|
ultest.File{Loc: "/home/user/files/file2.txt"},
|
|
|
|
)
|
|
|
|
})
|
2021-10-02 00:47:53 +01:00
|
|
|
|
|
|
|
t.Run("Pending", func(t *testing.T) {
|
|
|
|
state := ultest.Setup(commands,
|
|
|
|
ultest.WithPendingFile("sj://user/files/file1.txt"),
|
|
|
|
ultest.WithPendingFile("sj://user/files/file2.txt"),
|
|
|
|
ultest.WithPendingFile("sj://user/other_file1.txt"),
|
|
|
|
)
|
|
|
|
|
|
|
|
state.Succeed(t, "rm", "sj://user/files/file1.txt", "--pending").RequirePending(t,
|
|
|
|
ultest.File{Loc: "sj://user/files/file2.txt"},
|
|
|
|
ultest.File{Loc: "sj://user/other_file1.txt"},
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Pending Recursive", func(t *testing.T) {
|
|
|
|
state := ultest.Setup(commands,
|
|
|
|
ultest.WithPendingFile("sj://user/files/file1.txt"),
|
|
|
|
ultest.WithPendingFile("sj://user/files/file2.txt"),
|
|
|
|
ultest.WithPendingFile("sj://user/other_file1.txt"),
|
|
|
|
)
|
|
|
|
|
|
|
|
state.Succeed(t, "rm", "sj://user/files", "-r", "--pending").RequirePending(t,
|
|
|
|
ultest.File{Loc: "sj://user/other_file1.txt"},
|
|
|
|
)
|
|
|
|
})
|
2021-05-14 20:20:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestRmLocal(t *testing.T) {
|
2021-06-25 02:55:13 +01:00
|
|
|
t.Run("Basic", func(t *testing.T) {
|
|
|
|
state := ultest.Setup(commands,
|
|
|
|
ultest.WithFile("sj://user/file1.txt"),
|
|
|
|
ultest.WithFile("sj://user/file2.txt"),
|
|
|
|
ultest.WithFile("/home/user/file1.txt"),
|
|
|
|
ultest.WithFile("/home/user/file2.txt"),
|
|
|
|
)
|
2021-05-14 20:20:21 +01:00
|
|
|
|
2022-05-11 20:17:13 +01:00
|
|
|
state.Fail(t, "rm", "/home/user/file1.txt").RequireFiles(t,
|
2021-06-25 02:55:13 +01:00
|
|
|
ultest.File{Loc: "sj://user/file1.txt"},
|
|
|
|
ultest.File{Loc: "sj://user/file2.txt"},
|
2022-05-11 20:17:13 +01:00
|
|
|
ultest.File{Loc: "/home/user/file1.txt"},
|
2021-06-25 02:55:13 +01:00
|
|
|
ultest.File{Loc: "/home/user/file2.txt"},
|
|
|
|
)
|
|
|
|
})
|
2021-05-14 20:20:21 +01:00
|
|
|
|
2021-06-25 02:55:13 +01:00
|
|
|
t.Run("Recursive", func(t *testing.T) {
|
|
|
|
state := ultest.Setup(commands,
|
|
|
|
ultest.WithFile("sj://user/files/file1.txt"),
|
|
|
|
ultest.WithFile("sj://user/files/file2.txt"),
|
|
|
|
ultest.WithFile("/home/user/files/file1.txt"),
|
|
|
|
ultest.WithFile("/home/user/files/file2.txt"),
|
|
|
|
ultest.WithFile("/home/user/other_file1.txt"),
|
|
|
|
)
|
2021-05-14 20:20:21 +01:00
|
|
|
|
2022-05-11 20:17:13 +01:00
|
|
|
state.Fail(t, "rm", "/home/user/files", "-r").RequireFiles(t,
|
2021-06-25 02:55:13 +01:00
|
|
|
ultest.File{Loc: "sj://user/files/file1.txt"},
|
|
|
|
ultest.File{Loc: "sj://user/files/file2.txt"},
|
2022-05-11 20:17:13 +01:00
|
|
|
ultest.File{Loc: "/home/user/files/file1.txt"},
|
|
|
|
ultest.File{Loc: "/home/user/files/file2.txt"},
|
2021-06-25 02:55:13 +01:00
|
|
|
ultest.File{Loc: "/home/user/other_file1.txt"},
|
|
|
|
)
|
|
|
|
})
|
2021-05-14 20:20:21 +01:00
|
|
|
}
|