(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestFinch_RootDir(t *testing.T) { |
| 20 | t.Parallel() |
| 21 | |
| 22 | testCases := []struct { |
| 23 | name string |
| 24 | mockSvc func(*mocks.FinchFinderDeps) |
| 25 | wantErr error |
| 26 | want Finch |
| 27 | }{ |
| 28 | { |
| 29 | name: "happy path", |
| 30 | wantErr: nil, |
| 31 | want: Finch(`C:\Users\User\AppData\`), |
| 32 | mockSvc: func(deps *mocks.FinchFinderDeps) { |
| 33 | deps.EXPECT().Env("LOCALAPPDATA").Return(`C:\Users\User\AppData\`) |
| 34 | }, |
| 35 | }, |
| 36 | { |
| 37 | name: "failed to find the executable path", |
| 38 | want: "", |
| 39 | wantErr: fmt.Errorf("unexpected LOCALAPPDATA path %q", `\\network.path\home\test\"&someDir`), |
| 40 | mockSvc: func(deps *mocks.FinchFinderDeps) { |
| 41 | deps.EXPECT().Env("LOCALAPPDATA").Return(`\\network.path\home\test\"&someDir`) |
| 42 | }, |
| 43 | }, |
| 44 | } |
| 45 | |
| 46 | for _, tc := range testCases { |
| 47 | t.Run(tc.name, func(t *testing.T) { |
| 48 | t.Parallel() |
| 49 | |
| 50 | ctrl := gomock.NewController(t) |
| 51 | deps := mocks.NewFinchFinderDeps(ctrl) |
| 52 | tc.mockSvc(deps) |
| 53 | res, err := mockFinch.FinchRootDir(deps) |
| 54 | assert.Equal(t, Finch(res), tc.want) |
| 55 | assert.Equal(t, err, tc.wantErr) |
| 56 | }) |
| 57 | } |
| 58 | } |
nothing calls this directly
no test coverage detected