Files
kopia/cli/command_blob_show_test.go
T
Julio López fdf0159a17 refactor(general): cleanup various nits (#5618)
- use struct field initialization idiom
- clarify error message
- directly use s.rootctx in server request processing
- refactor: use require in e2e ACL test
- inline constant definition
- modernize with `strings.Cut`
- modernize with slices.Backward
- simplify timeFormat initialization
- refactor testing: check `Scanner.Err()` in testenv
- remove spurious parenthesis
- trueStr and falseStr consts
- use inheritPolicyString
- use const in cache info
- "bytes" const in ui task counters
- use common consts in gettool
2026-09-06 15:08:49 -07:00

39 lines
1.2 KiB
Go

package cli_test
import (
"strings"
"testing"
"github.com/kopia/kopia/tests/testenv"
)
func (s *formatSpecificTestSuite) TestBlobShow(t *testing.T) {
env := testenv.NewCLITest(t, s.formatFlags, testenv.NewInProcRunner(t))
env.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", env.RepoDir)
var hasEpochManager bool
for _, line := range env.RunAndExpectSuccess(t, "repository", "status") {
if strings.HasPrefix(line, "Epoch Manager:") && strings.Contains(line, "enabled") {
hasEpochManager = true
}
}
someQBlob, _, _ := strings.Cut(env.RunAndExpectSuccess(t, "blob", "list", "--prefix=q")[0], " ")
if hasEpochManager {
someXNBlob, _, _ := strings.Cut(env.RunAndExpectSuccess(t, "blob", "list", "--prefix=xn")[0], " ")
env.RunAndExpectSuccess(t, "blob", "show", someXNBlob)
env.RunAndExpectSuccess(t, "blob", "show", "--decrypt", someXNBlob)
} else {
someNBlob, _, _ := strings.Cut(env.RunAndExpectSuccess(t, "blob", "list", "--prefix=n")[0], " ")
env.RunAndExpectSuccess(t, "blob", "show", someNBlob)
env.RunAndExpectSuccess(t, "blob", "show", "--decrypt", someNBlob)
}
env.RunAndExpectSuccess(t, "blob", "show", someQBlob)
// --decrypt will be ignored
env.RunAndExpectSuccess(t, "blob", "show", "--decrypt", someQBlob)
}