(t *testing.T)
| 48 | } |
| 49 | |
| 50 | func platformLoadTests(t *testing.T) []loadTestCase { |
| 51 | return []loadTestCase{ |
| 52 | { |
| 53 | name: "happy path", |
| 54 | path: "/config.yaml", |
| 55 | mockSvc: func( |
| 56 | fs afero.Fs, |
| 57 | _ *mocks.Logger, |
| 58 | deps *mocks.LoadSystemDeps, |
| 59 | mem *mocks.Memory, |
| 60 | ecc *mocks.CommandCreator, |
| 61 | ctrl *gomock.Controller, |
| 62 | ) { |
| 63 | data := ` |
| 64 | memory: 4GiB |
| 65 | cpus: 8 |
| 66 | ` |
| 67 | require.NoError(t, afero.WriteFile(fs, "/config.yaml", []byte(data), 0o600)) |
| 68 | deps.EXPECT().NumCPU().Return(8) |
| 69 | // 12_884_901_888 == 12GiB |
| 70 | mem.EXPECT().TotalMemory().Return(uint64(12_884_901_888)) |
| 71 | c := mocks.NewCommand(ctrl) |
| 72 | ecc.EXPECT().Create("sw_vers", "-productVersion").Return(c) |
| 73 | c.EXPECT().Output().Return([]byte("14.0.0"), nil) |
| 74 | }, |
| 75 | want: makeConfig("vz", "4GiB", 8, false), |
| 76 | wantErr: nil, |
| 77 | }, |
| 78 | { |
| 79 | name: "config file exists, but is empty", |
| 80 | path: "/config.yaml", |
| 81 | mockSvc: func( |
| 82 | fs afero.Fs, |
| 83 | _ *mocks.Logger, |
| 84 | deps *mocks.LoadSystemDeps, |
| 85 | mem *mocks.Memory, |
| 86 | ecc *mocks.CommandCreator, |
| 87 | ctrl *gomock.Controller, |
| 88 | ) { |
| 89 | require.NoError(t, afero.WriteFile(fs, "/config.yaml", []byte(""), 0o600)) |
| 90 | deps.EXPECT().NumCPU().Return(4).Times(2) |
| 91 | mem.EXPECT().TotalMemory().Return(uint64(12_884_901_888)).Times(2) |
| 92 | c := mocks.NewCommand(ctrl) |
| 93 | ecc.EXPECT().Create("sw_vers", "-productVersion").Return(c) |
| 94 | c.EXPECT().Output().Return([]byte("14.0.0"), nil) |
| 95 | }, |
| 96 | want: makeConfig("vz", "6GiB", 2, false), |
| 97 | wantErr: nil, |
| 98 | }, |
| 99 | { |
| 100 | name: "config file exists, but contains only some fields", |
| 101 | path: "/config.yaml", |
| 102 | mockSvc: func( |
| 103 | fs afero.Fs, |
| 104 | _ *mocks.Logger, |
| 105 | deps *mocks.LoadSystemDeps, |
| 106 | mem *mocks.Memory, |
| 107 | ecc *mocks.CommandCreator, |
no test coverage detected