MCPcopy
hub / github.com/runfinch/finch / TestFinch_RootDir

Function TestFinch_RootDir

pkg/path/finch_windows_test.go:19–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func 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}

Callers

nothing calls this directly

Calls 7

EXPECTMethod · 0.95
NewFinchFinderDepsFunction · 0.92
FinchTypeAlias · 0.70
EnvMethod · 0.65
ErrorfMethod · 0.65
RunMethod · 0.65
FinchRootDirMethod · 0.45

Tested by

no test coverage detected