Update tests for new flag names

This commit is contained in:
Joel Watson 2020-11-10 11:18:21 -06:00
parent f29a28e038
commit 0369eb4a13
9 changed files with 90 additions and 15 deletions

View File

@ -31,7 +31,6 @@ func TestFormat(t *testing.T) {
TotalSize: 1,
TotalSizeKV: 1,
}
detailed := false
formatters := map[string]Formatter{
"pretty": newPrettyFormatter(),
@ -41,7 +40,7 @@ func TestFormat(t *testing.T) {
for fmtName, formatter := range formatters {
t.Run(fmtName, func(t *testing.T) {
actual, err := formatter.Format(&info, detailed)
actual, err := formatter.Format(&info)
require.NoError(t, err)
gName := fmt.Sprintf("%s", fmtName)

View File

@ -96,14 +96,14 @@ func TestSnapshotInspectCommand(t *testing.T) {
require.Equal(t, want, ui.OutputWriter.String())
}
func TestSnapshotInspectDetailedCommand(t *testing.T) {
func TestSnapshotInspectKVDetailsCommand(t *testing.T) {
filepath := "./testdata/backup-with-kv.snap"
filepath := "./testdata/backupWithKV.snap"
// Inspect the snapshot
ui := cli.NewMockUi()
c := New(ui)
args := []string{"-detailed", filepath}
args := []string{"-kvdetails", filepath}
code := c.Run(args)
if code != 0 {
@ -114,14 +114,14 @@ func TestSnapshotInspectDetailedCommand(t *testing.T) {
require.Equal(t, want, ui.OutputWriter.String())
}
func TestSnapshotInspectDetailedDepthCommand(t *testing.T) {
func TestSnapshotInspectKVDetailsDepthCommand(t *testing.T) {
filepath := "./testdata/backup-with-kv.snap"
filepath := "./testdata/backupWithKV.snap"
// Inspect the snapshot
ui := cli.NewMockUi()
c := New(ui)
args := []string{"-detailed", "-depth", "3", filepath}
args := []string{"-kvdetails", "-kvdepth", "3", filepath}
code := c.Run(args)
if code != 0 {
@ -132,14 +132,32 @@ func TestSnapshotInspectDetailedDepthCommand(t *testing.T) {
require.Equal(t, want, ui.OutputWriter.String())
}
func TestSnapshotInspectDetailedDepthFilterCommand(t *testing.T) {
func TestSnapshotInspectKVDetailsDepthFilterCommand(t *testing.T) {
filepath := "./testdata/backup-with-kv.snap"
filepath := "./testdata/backupWithKV.snap"
// Inspect the snapshot
ui := cli.NewMockUi()
c := New(ui)
args := []string{"-detailed", "-depth", "3", "-filter", "vault/logical", filepath}
args := []string{"-kvdetails", "-kvdepth", "3", "-kvfilter", "vault/logical", filepath}
code := c.Run(args)
if code != 0 {
t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
}
want := golden(t, t.Name(), ui.OutputWriter.String())
require.Equal(t, want, ui.OutputWriter.String())
}
func TestSnapshotInspectKVDetailsCommandNoDetailsFlag(t *testing.T) {
filepath := "./testdata/backupWithKV.snap"
// Inspect the snapshot
ui := cli.NewMockUi()
c := New(ui)
args := []string{"-kvdepth", "3", filepath}
code := c.Run(args)
if code != 0 {

View File

@ -9,8 +9,8 @@
KVS 27 12.3KB
Register 5 3.4KB
Index 11 285B
Session 1 199B
Autopilot 1 199B
Session 1 199B
CoordinateBatchUpdate 1 166B
Tombstone 2 146B
FederationState 1 139B

View File

@ -0,0 +1,44 @@
ID 2-12426-1604593650375
Size 17228
Index 12426
Term 2
Version 1
Type Count Size
---- ---- ----
KVS 27 12.3KB
Register 5 3.4KB
Index 11 285B
Autopilot 1 199B
Session 1 199B
CoordinateBatchUpdate 1 166B
Tombstone 2 146B
FederationState 1 139B
ChunkingState 1 12B
---- ---- ----
Total 16.8KB
Key Name Count Size
---- ---- ----
vault/sys/policy 3 3.3KB
vault/logical/0989e79e-06cd-5374-c8c0-4c6d675bc1c9 3 1.8KB
vault/core/leader 1 1.6KB
vault/sys/token 3 1KB
vault/core/mounts 1 675B
vault/core/wrapping 1 633B
vault/core/local-mounts 1 450B
vault/core/auth 1 423B
vault/core/cluster 2 388B
vault/core/keyring 1 320B
vault/core/master 1 237B
vault/core/seal-config 1 211B
vault/logical/5c018b68-3573-41d3-0c33-04bce60cd6b0 1 210B
vault/core/hsm 1 189B
vault/core/local-audit 1 185B
vault/core/local-auth 1 183B
vault/core/audit 1 179B
vault/core/lock 1 170B
vault/core/shamir-kek 1 159B
vault/sys/counters 1 155B
---- ---- ----
Total 12.3KB

View File

@ -9,8 +9,8 @@
KVS 27 12.3KB
Register 5 3.4KB
Index 11 285B
Session 1 199B
Autopilot 1 199B
Session 1 199B
CoordinateBatchUpdate 1 166B
Tombstone 2 146B
FederationState 1 139B

View File

@ -13,5 +13,13 @@
"Count": 2
}
],
"TotalSize": 1
"StatsKV": [
{
"Name": "msgKV",
"Sum": 1,
"Count": 2
}
],
"TotalSize": 1,
"TotalSizeKV": 1
}

View File

@ -8,4 +8,10 @@
---- ---- ----
msg 2 1B
---- ---- ----
Total 1B
Total 1B
Key Name Count Size
---- ---- ----
msgKV 2 1B
---- ---- ----
Total 1B