Add explicit templates vault view
This commit is contained in:
@@ -78,6 +78,44 @@ func TestVaultRecycleBinProjectsRecycleTree(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestVaultTemplatesProjectsTemplatesStorageRoot(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
model := vault.Model{
|
||||
Templates: []vault.Entry{
|
||||
{ID: "website-login", Title: "Website Login", Path: []string{"Templates", "Web"}},
|
||||
{ID: "ssh-login", Title: "SSH Login", Path: []string{"Templates", "Infra"}},
|
||||
},
|
||||
Groups: [][]string{
|
||||
{"Templates"},
|
||||
{"Templates", "Infra"},
|
||||
{"Templates", "Web"},
|
||||
{"keepass"},
|
||||
},
|
||||
}
|
||||
|
||||
view := VaultTemplates(model)
|
||||
|
||||
if got := view.ChildGroups(nil); !slices.Equal(got, []string{"Infra", "Web"}) {
|
||||
t.Fatalf("VaultTemplates(model).ChildGroups(nil) = %v, want [Infra Web]", got)
|
||||
}
|
||||
|
||||
gotEntries := view.EntriesInPath([]string{"Web"})
|
||||
if len(gotEntries) != 1 || !slices.Equal(gotEntries[0].Path, []string{"Web"}) {
|
||||
t.Fatalf("VaultTemplates(model).EntriesInPath([Web]) = %#v, want logical path [Web]", gotEntries)
|
||||
}
|
||||
|
||||
if got := view.ToPhysicalPath(nil); !slices.Equal(got, []string{"Templates"}) {
|
||||
t.Fatalf("VaultTemplates(model).ToPhysicalPath(nil) = %v, want [Templates]", got)
|
||||
}
|
||||
if got := view.ToPhysicalPath([]string{"Web"}); !slices.Equal(got, []string{"Templates", "Web"}) {
|
||||
t.Fatalf("VaultTemplates(model).ToPhysicalPath([Web]) = %v, want [Templates Web]", got)
|
||||
}
|
||||
if got := view.FromPhysicalPath([]string{"Templates", "Web"}); !slices.Equal(got, []string{"Web"}) {
|
||||
t.Fatalf("VaultTemplates(model).FromPhysicalPath([Templates Web]) = %v, want [Web]", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVaultReturnsPhysicalPathsUnchanged(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user