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

Function TestLoad

pkg/config/config_test.go:34–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32}
33
34func TestLoad(t *testing.T) {
35 t.Parallel()
36 testCases := []loadTestCase{
37 {
38 name: "config file does not contain valid YAML",
39 path: "/config.yaml",
40 mockSvc: func(
41 fs afero.Fs,
42 _ *mocks.Logger,
43 _ *mocks.LoadSystemDeps,
44 _ *mocks.Memory,
45 _ *mocks.CommandCreator,
46 _ *gomock.Controller,
47 ) {
48 require.NoError(t, afero.WriteFile(fs, "/config.yaml", []byte("this isn't YAML"), 0o600))
49 },
50 want: nil,
51 wantErr: fmt.Errorf(
52 "failed to unmarshal config file: %w",
53 &yaml.TypeError{Errors: []string{"line 1: cannot unmarshal !!str `this is...` into config.Finch"}},
54 ),
55 },
56 }
57
58 testCases = append(testCases, platformLoadTests(t)...)
59
60 for _, tc := range testCases {
61 t.Run(tc.name, func(t *testing.T) {
62 t.Parallel()
63
64 ctrl := gomock.NewController(t)
65 l := mocks.NewLogger(ctrl)
66 deps := mocks.NewLoadSystemDeps(ctrl)
67 mem := mocks.NewMemory(ctrl)
68 ecc := mocks.NewCommandCreator(ctrl)
69 fs := afero.NewMemMapFs()
70
71 tc.mockSvc(fs, l, deps, mem, ecc, ctrl)
72
73 got, gotErr := Load(fs, tc.path, l, deps, mem, ecc)
74 require.Equal(t, tc.wantErr, gotErr)
75 assert.Equal(t, tc.want, got)
76 })
77 }
78}
79
80func Test_writeConfig(t *testing.T) {
81 t.Parallel()

Callers

nothing calls this directly

Calls 8

NewLoggerFunction · 0.92
NewLoadSystemDepsFunction · 0.92
NewMemoryFunction · 0.92
NewCommandCreatorFunction · 0.92
LoadFunction · 0.85
platformLoadTestsFunction · 0.70
ErrorfMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected