MCPcopy
hub / github.com/wagoodman/dive / initializeTestViewModel

Function initializeTestViewModel

runtime/ui/viewmodel/filetree_test.go:76–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func initializeTestViewModel(t *testing.T) *FileTreeViewModel {
77 result := docker.TestAnalysisFromArchive(t, "../../../.data/test-docker-image.tar")
78
79 cache := filetree.NewComparer(result.RefTrees)
80 errors := cache.BuildCache()
81 if len(errors) > 0 {
82 t.Fatalf("%s: unable to build cache: %d errors", t.Name(), len(errors))
83 }
84
85 format.Selected = color.New(color.ReverseVideo, color.Bold).SprintFunc()
86
87 treeStack, failedPaths, err := filetree.StackTreeRange(result.RefTrees, 0, 0)
88 if len(failedPaths) > 0 {
89 t.Errorf("expected no filepath errors, got %d", len(failedPaths))
90 }
91 if err != nil {
92 t.Fatalf("%s: unable to stack trees: %v", t.Name(), err)
93 }
94 vm, err := NewFileTreeViewModel(treeStack, result.RefTrees, cache)
95 if err != nil {
96 t.Fatalf("%s: unable to create tree ViewModel: %+v", t.Name(), err)
97 }
98 return vm
99}
100
101func runTestCase(t *testing.T, vm *FileTreeViewModel, width, height int, filterRegex *regexp.Regexp) {
102 err := vm.Update(filterRegex, width, height)

Callers 14

TestFileTreeGoCaseFunction · 0.85
TestFileTreeNoAttributesFunction · 0.85
TestFileTreeDirCollapseFunction · 0.85
TestFileTreeSelectLayerFunction · 0.85
TestFileTreePageDownFunction · 0.85
TestFileTreePageUpFunction · 0.85
TestFileTreeFilterTreeFunction · 0.85

Calls 6

BuildCacheMethod · 0.95
TestAnalysisFromArchiveFunction · 0.92
NewComparerFunction · 0.92
StackTreeRangeFunction · 0.92
NewFileTreeViewModelFunction · 0.85
NameMethod · 0.65

Tested by

no test coverage detected