Skip to content

Commit 3783a2b

Browse files
committed
filesystem: remove unused mock function
Remove mock of 'UserHomeDir()' for the 'FileSystem' interface leftover from an earlier iteration of de58f24 (repo: add more GetRepositories() tests, fix bug, 2023-01-31). The function was removed by the time the commit was merged, so the mock can safely be deleted. Add a call to 'mock.AssertExpectationsForObjects()' to ensure all mocked functions are called. This function should be called in all mocked unit tests to ensure similar issues do not occur in the future. Signed-off-by: Victoria Dye <[email protected]>
1 parent 02b8ade commit 3783a2b

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

internal/core/repo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ func TestRepos_GetRepositories(t *testing.T) {
9797

9898
for _, tt := range getRepositoriesTests {
9999
t.Run(tt.title, func(t *testing.T) {
100-
testFileSystem.On("UserHomeDir").Return("/my/test/dir", nil)
101100
testFileSystem.On("ReadFileLines",
102101
mock.AnythingOfType("string"),
103102
).Return(tt.readFileLines.First, tt.readFileLines.Second).Once()
104103

105104
actual, err := repoProvider.GetRepositories(context.Background())
105+
mock.AssertExpectationsForObjects(t, testUserProvider, testFileSystem)
106106

107107
if tt.expectedErr {
108108
assert.NotNil(t, err, "Expected error")

internal/testhelpers/mocks.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@ func (m *MockFileSystem) ReadFileLines(filename string) ([]string, error) {
196196
return fnArgs.Get(0).([]string), fnArgs.Error(1)
197197
}
198198

199-
func (m *MockFileSystem) UserHomeDir() (string, error) {
200-
fnArgs := m.Called()
201-
return fnArgs.String(0), fnArgs.Error(1)
202-
}
203-
204199
type MockGitHelper struct {
205200
mock.Mock
206201
}

0 commit comments

Comments
 (0)