From 87f1f5281ce129df67193a5a5bb3ba6757249ac0 Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Sat, 5 Jun 2021 09:03:49 -0700 Subject: [PATCH] cli: added tests for benchmark subcommands --- cli/command_benchmark_test.go | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cli/command_benchmark_test.go diff --git a/cli/command_benchmark_test.go b/cli/command_benchmark_test.go new file mode 100644 index 000000000..7eb5d781a --- /dev/null +++ b/cli/command_benchmark_test.go @@ -0,0 +1,42 @@ +package cli_test + +import ( + "bytes" + "io/ioutil" + "path/filepath" + "testing" + + "github.com/kopia/kopia/internal/testutil" + "github.com/kopia/kopia/tests/testenv" +) + +func TestCommandBenchmarkCrypto(t *testing.T) { + t.Parallel() + + runner := testenv.NewInProcRunner(t) + e := testenv.NewCLITest(t, runner) + + e.RunAndExpectSuccess(t, "benchmark", "crypto", "--repeat=1", "--block-size=1KB", "--print-options") +} + +func TestCommandBenchmarkSpliter(t *testing.T) { + t.Parallel() + + runner := testenv.NewInProcRunner(t) + e := testenv.NewCLITest(t, runner) + + e.RunAndExpectSuccess(t, "benchmark", "splitter", "--block-count=1", "--print-options") +} + +func TestCommandBenchmarkCompression(t *testing.T) { + t.Parallel() + + runner := testenv.NewInProcRunner(t) + e := testenv.NewCLITest(t, runner) + + testFile := filepath.Join(testutil.TempDirectory(t), "testfile.txt") + ioutil.WriteFile(testFile, bytes.Repeat([]byte{1, 2, 3, 4, 5, 6}, 10000), 0600) + + e.RunAndExpectSuccess(t, "benchmark", "compression", "--data-file", testFile, "--repeat=2", "--verify-stable", "--print-options") + e.RunAndExpectSuccess(t, "benchmark", "compression", "--data-file", testFile, "--repeat=2", "--by-size") +}