mirror of
https://github.com/kopia/kopia.git
synced 2026-01-25 23:08:01 -05:00
additional integration tests
This commit is contained in:
2
Makefile
2
Makefile
@@ -82,7 +82,7 @@ vtest:
|
||||
|
||||
integration-tests:
|
||||
go build -o $(RELEASE_TMP_DIR)/integration/kopia -ldflags $(LDARGS) github.com/kopia/kopia
|
||||
KOPIA_EXE=$(RELEASE_TMP_DIR)/integration/kopia go test -timeout 30s github.com/kopia/kopia/tests/...
|
||||
KOPIA_EXE=$(RELEASE_TMP_DIR)/integration/kopia go test -timeout 30s -v github.com/kopia/kopia/tests/...
|
||||
|
||||
godoc:
|
||||
godoc -http=:33333
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
var (
|
||||
blockIndexListCommand = blockIndexCommands.Command("list", "List block indexes").Alias("ls")
|
||||
blockIndexListAll = blockIndexListCommand.Flag("all", "List all blocks, not just active ones").Short('a').Bool()
|
||||
blockIndexListSummary = blockIndexListCommand.Flag("summary", "Display block summary").Bool()
|
||||
)
|
||||
|
||||
func runListBlockIndexesAction(context *kingpin.ParseContext) error {
|
||||
@@ -34,7 +35,9 @@ func runListBlockIndexesAction(context *kingpin.ParseContext) error {
|
||||
fmt.Printf("%-70v %10v %v\n", b.BlockID, b.Length, b.Timestamp.Local().Format(timeFormatPrecise))
|
||||
}
|
||||
|
||||
fmt.Printf("total %v blocks\n", len(blks))
|
||||
if *blockIndexListSummary {
|
||||
fmt.Printf("total %v blocks\n", len(blks))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
const repoPassword = "qWQPJ2hiiLgWRRCr"
|
||||
@@ -108,6 +106,17 @@ func TestRepo(t *testing.T) {
|
||||
if got, want := len(sources), 3; got != want {
|
||||
t.Errorf("unexpected number of sources: %v, want %v in %#v", got, want, sources)
|
||||
}
|
||||
|
||||
// expect 5 blocks, each snapshot creation adds one index block.
|
||||
e.runAndVerifyOutputLineCount(t, 5, "blockindex", "ls")
|
||||
e.runAndExpectSuccess(t, "blockindex", "optimize")
|
||||
e.runAndVerifyOutputLineCount(t, 1, "blockindex", "ls")
|
||||
e.runAndVerifyOutputLineCount(t, 6, "blockindex", "ls", "--all")
|
||||
|
||||
e.runAndExpectSuccess(t, "snapshot", "create", ".", dir1, dir2)
|
||||
e.runAndVerifyOutputLineCount(t, 2, "blockindex", "ls")
|
||||
|
||||
//t.Fail()
|
||||
}
|
||||
|
||||
func (e *testenv) runAndExpectSuccess(t *testing.T, args ...string) []string {
|
||||
@@ -118,6 +127,14 @@ func (e *testenv) runAndExpectSuccess(t *testing.T, args ...string) []string {
|
||||
return stdout
|
||||
}
|
||||
|
||||
func (e *testenv) runAndVerifyOutputLineCount(t *testing.T, wantLines int, args ...string) []string {
|
||||
lines := e.runAndExpectSuccess(t, args...)
|
||||
if len(lines) != wantLines {
|
||||
t.Errorf("unexpected list of results of 'kopia %v': %v (%v lines), wanted %v", strings.Join(args, " "), lines, len(lines), wantLines)
|
||||
}
|
||||
return lines
|
||||
}
|
||||
|
||||
func (e *testenv) run(t *testing.T, args ...string) ([]string, error) {
|
||||
t.Logf("running 'kopia %v'", strings.Join(args, " "))
|
||||
cmdArgs := append(append([]string(nil), e.fixedArgs...), args...)
|
||||
@@ -134,7 +151,6 @@ func listSnapshotsAndExpectSuccess(t *testing.T, e *testenv, targets ...string)
|
||||
}
|
||||
|
||||
func createDirectory(dirname string, depth int) error {
|
||||
log.Printf("createDirectory(%q,%v)", dirname, depth)
|
||||
if err := os.MkdirAll(dirname, 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -224,7 +240,8 @@ func mustParseSourceInfo(t *testing.T, l string) sourceInfo {
|
||||
}
|
||||
|
||||
func splitLines(s string) []string {
|
||||
if strings.TrimSpace(s) == "" {
|
||||
s = strings.TrimSpace(s)
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user