Files
kopia/cli/command_cache_sync_test.go
Jarek Kowalski 5179ad2cd2 cli: test + misc improvements (#1083)
* cli: Added --max-examples-per-bucket flag to 'kopia snapshot estimate'

Added and cleaned up a bunch of unit tests.

Fixes #1054

* cli: misc tests to increase code coverage of the cli package

* ci: move code coverage run into separate GH job
2021-05-17 21:47:11 -07:00

42 lines
1.5 KiB
Go

package cli_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/kopia/kopia/internal/testutil"
"github.com/kopia/kopia/tests/testenv"
)
func TestCacheClearSync(t *testing.T) {
env := testenv.NewCLITest(t, testenv.NewInProcRunner(t))
emptyDir := testutil.TempDirectory(t)
env.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", env.RepoDir)
env.RunAndExpectSuccess(t, "snapshot", "create", emptyDir)
env.RunAndExpectSuccess(t, "snapshot", "create", emptyDir)
env.RunAndExpectSuccess(t, "snapshot", "create", emptyDir)
env.RunAndExpectSuccess(t, "snapshot", "create", emptyDir)
env.RunAndExpectSuccess(t, "snapshot", "create", emptyDir)
oldMetadataLine := mustGetLineContaining(t, env.RunAndExpectSuccess(t, "cache", "info"), "metadata")
oldMetadataLine2 := mustGetLineContaining(t, env.RunAndExpectSuccess(t, "cache", "info"), "metadata")
require.Equal(t, oldMetadataLine, oldMetadataLine2)
env.RunAndExpectSuccess(t, "cache", "clear")
newMetadataLine := mustGetLineContaining(t, env.RunAndExpectSuccess(t, "cache", "info"), "metadata")
require.NotEqual(t, oldMetadataLine, newMetadataLine)
env.RunAndExpectSuccess(t, "cache", "sync")
newerMetadataLine := mustGetLineContaining(t, env.RunAndExpectSuccess(t, "cache", "info"), "metadata")
env.RunAndExpectSuccess(t, "cache", "sync")
newerMetadataLine2 := mustGetLineContaining(t, env.RunAndExpectSuccess(t, "cache", "info"), "metadata")
require.NotEqual(t, newerMetadataLine, newMetadataLine)
require.Equal(t, newerMetadataLine, newerMetadataLine2)
}