(t *testing.T)
| 32 | } |
| 33 | |
| 34 | func 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 | |
| 80 | func Test_writeConfig(t *testing.T) { |
| 81 | t.Parallel() |
nothing calls this directly
no test coverage detected