MCPcopy
hub / github.com/cli/cli / TestManager_List

Function TestManager_List

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

Source from the content-addressed store, hash-verified

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