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

Function platformLoadTests

pkg/config/config_darwin_test.go:50–184  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func 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 := `
64memory: 4GiB
65cpus: 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,

Callers 1

TestLoadFunction · 0.70

Calls 10

EXPECTMethod · 0.95
NewCommandFunction · 0.92
makeConfigFunction · 0.85
makeExperimentalConfigFunction · 0.85
NumCPUMethod · 0.65
TotalMemoryMethod · 0.65
CreateMethod · 0.65
OutputMethod · 0.65
InfofMethod · 0.65
EXPECTMethod · 0.45

Tested by

no test coverage detected