MCPcopy Create free account
hub / github.com/cli/cli / TestManager_List

Function TestManager_List

pkg/cmd/extension/manager_test.go:74–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestManager_List(t *testing.T) {
75 dataDir := t.TempDir()
76 updateDir := t.TempDir()
77 assert.NoError(t, stubExtension(filepath.Join(dataDir, "extensions", "gh-hello", "gh-hello")))
78 assert.NoError(t, stubExtension(filepath.Join(dataDir, "extensions", "gh-two", "gh-two")))
79
80 assert.NoError(t, stubBinaryExtension(
81 filepath.Join(dataDir, "extensions", "gh-bin-ext"),
82 binManifest{
83 Owner: "owner",
84 Name: "gh-bin-ext",
85 Host: "example.com",
86 Tag: "v1.0.1",
87 }))
88
89 dirOne := filepath.Join(dataDir, "extensions", "gh-hello")
90 dirTwo := filepath.Join(dataDir, "extensions", "gh-two")
91 gc, gcOne, gcTwo := &mockGitClient{}, &mockGitClient{}, &mockGitClient{}
92 gc.On("ForRepo", dirOne).Return(gcOne).Once()
93 gc.On("ForRepo", dirTwo).Return(gcTwo).Once()
94
95 m := newTestManager(dataDir, updateDir, nil, gc, nil)
96 exts := m.List()
97
98 assert.Equal(t, 3, len(exts))
99 assert.Equal(t, "bin-ext", exts[0].Name())
100 assert.Equal(t, "hello", exts[1].Name())
101 assert.Equal(t, "two", exts[2].Name())
102 gc.AssertExpectations(t)
103 gcOne.AssertExpectations(t)
104 gcTwo.AssertExpectations(t)
105}
106
107func TestManager_list_includeMetadata(t *testing.T) {
108 dataDir := t.TempDir()

Callers

nothing calls this directly

Calls 7

stubExtensionFunction · 0.85
stubBinaryExtensionFunction · 0.85
newTestManagerFunction · 0.85
JoinMethod · 0.80
EqualMethod · 0.80
ListMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected