From 3c039f176ccaaa33690f78cdc738bd5ffa5a729c Mon Sep 17 00:00:00 2001 From: Metbcy Date: Sat, 23 May 2026 00:00:18 +0000 Subject: [PATCH] chore: remove go.uber.org/mock dependency Replace the generated mocks under pkg/infoutil/infoutilmock and the inline gomock-based MockParse in pkg/cmd/builder/build_test.go with hand-rolled fakes that use function fields. This drops the go.uber.org/mock require from go.mod / go.sum. Fixes #3325 Signed-off-by: Metbcy --- go.mod | 1 - go.sum | 2 - pkg/cmd/builder/build_test.go | 149 ++++++++++----------- pkg/infoutil/infoutil_windows_test.go | 125 +++++++---------- pkg/infoutil/infoutilmock/infoutil_mock.go | 105 +++++---------- 5 files changed, 151 insertions(+), 231 deletions(-) diff --git a/go.mod b/go.mod index 20c5b71c3cd..23e37f00d00 100644 --- a/go.mod +++ b/go.mod @@ -63,7 +63,6 @@ require ( github.com/vishvananda/netlink v1.3.1 //gomodjail:unconfined github.com/vishvananda/netns v0.0.5 //gomodjail:unconfined github.com/yuchanns/srslog v1.1.0 - go.uber.org/mock v0.6.0 go.yaml.in/yaml/v3 v3.0.4 golang.org/x/crypto v0.51.0 golang.org/x/net v0.54.0 diff --git a/go.sum b/go.sum index 17e84692a0d..3622145104b 100644 --- a/go.sum +++ b/go.sum @@ -350,8 +350,6 @@ go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= -go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= diff --git a/pkg/cmd/builder/build_test.go b/pkg/cmd/builder/build_test.go index 246c64efc17..6566fdd46d4 100644 --- a/pkg/cmd/builder/build_test.go +++ b/pkg/cmd/builder/build_test.go @@ -19,104 +19,99 @@ package builder import ( "fmt" "path/filepath" - "reflect" "runtime" "testing" specs "github.com/opencontainers/image-spec/specs-go/v1" - "go.uber.org/mock/gomock" "gotest.tools/v3/assert" ) -type MockParse struct { - ctrl *gomock.Controller - recorder *MockParseRecorder +// fakePlatformParser is a hand-rolled test double for PlatformParser. +// Tests assign the function fields to control behavior. +type fakePlatformParser struct { + ParseFunc func(platform string) (specs.Platform, error) + DefaultSpecFunc func() specs.Platform } -type MockParseRecorder struct { - mock *MockParse -} - -func newMockParser(ctrl *gomock.Controller) *MockParse { - mock := &MockParse{ctrl: ctrl} - mock.recorder = &MockParseRecorder{mock} - return mock -} - -func (m *MockParse) EXPECT() *MockParseRecorder { - return m.recorder -} - -func (m *MockParse) Parse(platform string) (specs.Platform, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Parse") - ret0, _ := ret[0].(specs.Platform) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -func (m *MockParseRecorder) Parse(platform string) *gomock.Call { - m.mock.ctrl.T.Helper() - return m.mock.ctrl.RecordCallWithMethodType(m.mock, "Parse", reflect.TypeOf((*MockParse)(nil).Parse)) -} - -func (m *MockParse) DefaultSpec() specs.Platform { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DefaultSpec") - ret0, _ := ret[0].(specs.Platform) - return ret0 +func (f *fakePlatformParser) Parse(platform string) (specs.Platform, error) { + if f.ParseFunc == nil { + return specs.Platform{}, nil + } + return f.ParseFunc(platform) } -func (m *MockParseRecorder) DefaultSpec() *gomock.Call { - m.mock.ctrl.T.Helper() - return m.mock.ctrl.RecordCallWithMethodType(m.mock, "DefaultSpec", reflect.TypeOf((*MockParse)(nil).DefaultSpec)) +func (f *fakePlatformParser) DefaultSpec() specs.Platform { + if f.DefaultSpecFunc == nil { + return specs.Platform{} + } + return f.DefaultSpecFunc() } func TestIsMatchingRuntimePlatform(t *testing.T) { t.Parallel() testCases := []struct { - name string - mock func(*MockParse) - want bool + name string + parser *fakePlatformParser + want bool }{ { name: "Image is shareable when Runtime and build platform match for os, arch and variant", - mock: func(mockParser *MockParse) { - mockParser.EXPECT().Parse("test").Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}, nil) - mockParser.EXPECT().DefaultSpec().Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}) + parser: &fakePlatformParser{ + ParseFunc: func(string) (specs.Platform, error) { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}, nil + }, + DefaultSpecFunc: func() specs.Platform { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"} + }, }, want: true, }, { name: "Image is shareable when Runtime and build platform match for os, arch. Variant is not defined", - mock: func(mockParser *MockParse) { - mockParser.EXPECT().Parse("test").Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: ""}, nil) - mockParser.EXPECT().DefaultSpec().Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}) + parser: &fakePlatformParser{ + ParseFunc: func(string) (specs.Platform, error) { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: ""}, nil + }, + DefaultSpecFunc: func() specs.Platform { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"} + }, }, want: true, }, { name: "Image is not shareable when Runtime and build platform donot math OS", - mock: func(mockParser *MockParse) { - mockParser.EXPECT().Parse("test").Return(specs.Platform{OS: "OS", Architecture: "mockArch", Variant: ""}, nil) - mockParser.EXPECT().DefaultSpec().Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}) + parser: &fakePlatformParser{ + ParseFunc: func(string) (specs.Platform, error) { + return specs.Platform{OS: "OS", Architecture: "mockArch", Variant: ""}, nil + }, + DefaultSpecFunc: func() specs.Platform { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"} + }, }, want: false, }, { name: "Image is not shareable when Runtime and build platform donot math Arch", - mock: func(mockParser *MockParse) { - mockParser.EXPECT().Parse("test").Return(specs.Platform{OS: "mockOS", Architecture: "Arch", Variant: ""}, nil) - mockParser.EXPECT().DefaultSpec().Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}) + parser: &fakePlatformParser{ + ParseFunc: func(string) (specs.Platform, error) { + return specs.Platform{OS: "mockOS", Architecture: "Arch", Variant: ""}, nil + }, + DefaultSpecFunc: func() specs.Platform { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"} + }, }, want: false, }, { name: "Image is not shareable when Runtime and build platform donot math Variant", - mock: func(mockParser *MockParse) { - mockParser.EXPECT().Parse("test").Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "Variant"}, nil) - mockParser.EXPECT().DefaultSpec().Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}) + parser: &fakePlatformParser{ + ParseFunc: func(string) (specs.Platform, error) { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "Variant"}, nil + }, + DefaultSpecFunc: func() specs.Platform { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"} + }, }, want: false, }, @@ -126,11 +121,7 @@ func TestIsMatchingRuntimePlatform(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() - - ctrl := gomock.NewController(t) - mockParser := newMockParser(ctrl) - tc.mock(mockParser) - r := isMatchingRuntimePlatform("test", mockParser) + r := isMatchingRuntimePlatform("test", tc.parser) assert.Equal(t, r, tc.want, tc.name) }) } @@ -141,7 +132,7 @@ func TestIsBuildPlatformDefault(t *testing.T) { testCases := []struct { name string - mock func(*MockParse) + parser *fakePlatformParser platform []string want bool }{ @@ -153,18 +144,26 @@ func TestIsBuildPlatformDefault(t *testing.T) { { name: "Image is shareable when Runtime and build platform match for os, arch and variant", platform: []string{"test"}, - mock: func(mockParser *MockParse) { - mockParser.EXPECT().Parse("test").Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}, nil) - mockParser.EXPECT().DefaultSpec().Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}) + parser: &fakePlatformParser{ + ParseFunc: func(string) (specs.Platform, error) { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}, nil + }, + DefaultSpecFunc: func() specs.Platform { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"} + }, }, want: true, }, { name: "Image is not shareable when Runtime build platform dont match", platform: []string{"test"}, - mock: func(mockParser *MockParse) { - mockParser.EXPECT().Parse("test").Return(specs.Platform{OS: "OS", Architecture: "mockArch", Variant: "mockVariant"}, nil) - mockParser.EXPECT().DefaultSpec().Return(specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"}) + parser: &fakePlatformParser{ + ParseFunc: func(string) (specs.Platform, error) { + return specs.Platform{OS: "OS", Architecture: "mockArch", Variant: "mockVariant"}, nil + }, + DefaultSpecFunc: func() specs.Platform { + return specs.Platform{OS: "mockOS", Architecture: "mockArch", Variant: "mockVariant"} + }, }, want: false, }, @@ -179,13 +178,11 @@ func TestIsBuildPlatformDefault(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() - - ctrl := gomock.NewController(t) - mockParser := newMockParser(ctrl) - if len(tc.platform) == 1 { - tc.mock(mockParser) + parser := tc.parser + if parser == nil { + parser = &fakePlatformParser{} } - r := isBuildPlatformDefault(tc.platform, mockParser) + r := isBuildPlatformDefault(tc.platform, parser) assert.Equal(t, r, tc.want, tc.name) }) } diff --git a/pkg/infoutil/infoutil_windows_test.go b/pkg/infoutil/infoutil_windows_test.go index 173cf1927e4..27e8a9c4c3a 100644 --- a/pkg/infoutil/infoutil_windows_test.go +++ b/pkg/infoutil/infoutil_windows_test.go @@ -19,7 +19,6 @@ package infoutil import ( "testing" - "go.uber.org/mock/gomock" "golang.org/x/sys/windows" "golang.org/x/sys/windows/registry" "gotest.tools/v3/assert" @@ -27,34 +26,24 @@ import ( mocks "github.com/containerd/nerdctl/v2/pkg/infoutil/infoutilmock" ) -func setUpMocks(t *testing.T) *mocks.MockWindowsInfoUtil { - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - mockInfoUtil := mocks.NewMockWindowsInfoUtil(ctrl) - - // Mock registry value: CurrentBuildNumber - mockInfoUtil. - EXPECT(). - GetRegistryStringValue(gomock.Any(), gomock.Any(), "CurrentBuildNumber"). - Return("19041", nil). - AnyTimes() - - // Mock registry value: DisplayVersion - mockInfoUtil. - EXPECT(). - GetRegistryStringValue(gomock.Any(), gomock.Any(), "DisplayVersion"). - Return("22H4", nil). - AnyTimes() - - // Mock registry value: UBR - mockInfoUtil. - EXPECT(). - GetRegistryIntValue(gomock.Any(), gomock.Any(), "UBR"). - Return(558, nil). - AnyTimes() - - return mockInfoUtil +func newRegistryFake() *mocks.FakeWindowsInfoUtil { + f := mocks.NewFakeWindowsInfoUtil() + f.GetRegistryStringValueFunc = func(_ registry.Key, _ string, name string) (string, error) { + switch name { + case "CurrentBuildNumber": + return "19041", nil + case "DisplayVersion": + return "22H4", nil + } + return "", nil + } + f.GetRegistryIntValueFunc = func(_ registry.Key, _ string, name string) (int, error) { + if name == "UBR" { + return 558, nil + } + return 0, nil + } + return f } const ( @@ -63,8 +52,6 @@ const ( ) func TestDistroName(t *testing.T) { - mockInfoUtil := setUpMocks(t) - baseVersion := windows.OsVersionInfoEx{ MajorVersion: 10, MinorVersion: 0, @@ -86,13 +73,13 @@ func TestDistroName(t *testing.T) { } for _, tt := range tests { - // Mock sys/windows RtlGetVersion + fake := newRegistryFake() osvi := baseVersion osvi.ProductType = tt.productType - mockInfoUtil.EXPECT().RtlGetVersion().Return(&osvi).Times(1) + fake.RtlGetVersionFunc = func() *windows.OsVersionInfoEx { return &osvi } t.Run(tt.expected, func(t *testing.T) { - actual, err := distroName(mockInfoUtil) + actual, err := distroName(fake) assert.Equal(t, tt.expected, actual, "distroName should return the name of the operating system") assert.NilError(t, err) }) @@ -100,73 +87,54 @@ func TestDistroName(t *testing.T) { } func TestDistroNameError(t *testing.T) { - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - mockInfoUtil := mocks.NewMockWindowsInfoUtil(ctrl) - - mockInfoUtil.EXPECT().RtlGetVersion().Return(nil).Times(0) - mockInfoUtil. - EXPECT(). - GetRegistryStringValue(gomock.Any(), gomock.Any(), gomock.Any()). - Return("19041", registry.ErrNotExist).AnyTimes() + fake := mocks.NewFakeWindowsInfoUtil() + fake.GetRegistryStringValueFunc = func(_ registry.Key, _ string, _ string) (string, error) { + return "19041", registry.ErrNotExist + } - actual, err := distroName(mockInfoUtil) + actual, err := distroName(fake) assert.ErrorContains(t, err, registry.ErrNotExist.Error(), "distroName should return an error on error") assert.Equal(t, "", actual, "distroname should return an empty string on error") } func TestGetKernelVersion(t *testing.T) { - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - mockInfoUtil := mocks.NewMockWindowsInfoUtil(ctrl) - - // Mock registry value: BuildLabEx - mockInfoUtil. - EXPECT(). - GetRegistryStringValue(gomock.Any(), gomock.Any(), "BuildLabEx"). - Return("10240.16412.amd64fre.th1.150729-1800", nil). - Times(1) + fake := mocks.NewFakeWindowsInfoUtil() + fake.GetRegistryStringValueFunc = func(_ registry.Key, _ string, name string) (string, error) { + if name == "BuildLabEx" { + return "10240.16412.amd64fre.th1.150729-1800", nil + } + return "", nil + } baseVersion := windows.OsVersionInfoEx{ MajorVersion: 10, MinorVersion: 0, BuildNumber: 19041, } + fake.RtlGetVersionFunc = func() *windows.OsVersionInfoEx { + v := baseVersion + return &v + } expected := "10.0 19041 (10240.16412.amd64fre.th1.150729-1800)" - // Mock sys/windows RtlGetVersion - osvi := baseVersion - mockInfoUtil.EXPECT().RtlGetVersion().Return(&osvi).Times(1) - - actual, err := getKernelVersion(mockInfoUtil) + actual, err := getKernelVersion(fake) assert.NilError(t, err) assert.Equal(t, expected, actual, "getKernelVersion should return the kernel version") } func TestGetKernelVersionError(t *testing.T) { - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - mockInfoUtil := mocks.NewMockWindowsInfoUtil(ctrl) - - mockInfoUtil.EXPECT().RtlGetVersion().Return(nil).Times(0) - mockInfoUtil. - EXPECT(). - GetRegistryStringValue(gomock.Any(), gomock.Any(), gomock.Any()). - Return("", registry.ErrNotExist).Times(1) + fake := mocks.NewFakeWindowsInfoUtil() + fake.GetRegistryStringValueFunc = func(_ registry.Key, _ string, _ string) (string, error) { + return "", registry.ErrNotExist + } - actual, err := getKernelVersion(mockInfoUtil) + actual, err := getKernelVersion(fake) assert.ErrorContains(t, err, registry.ErrNotExist.Error(), "getKernelVersion should return an error on error") assert.Equal(t, "", actual, "getKernelVersion should return an empty string on error") } func TestIsWindowsServer(t *testing.T) { - ctrl := gomock.NewController(t) - defer ctrl.Finish() - tests := []struct { productType string osvi windows.OsVersionInfoEx @@ -189,12 +157,13 @@ func TestIsWindowsServer(t *testing.T) { }, } - mockSysCall := mocks.NewMockWindowsInfoUtil(ctrl) for _, tt := range tests { - mockSysCall.EXPECT().RtlGetVersion().Return(&tt.osvi) + tt := tt + fake := mocks.NewFakeWindowsInfoUtil() + fake.RtlGetVersionFunc = func() *windows.OsVersionInfoEx { return &tt.osvi } t.Run(tt.productType, func(t *testing.T) { - actual := isWindowsServer(mockSysCall) + actual := isWindowsServer(fake) assert.Equal(t, tt.expected, actual, "isWindowsServer should return true on Windows Server") }) } diff --git a/pkg/infoutil/infoutilmock/infoutil_mock.go b/pkg/infoutil/infoutilmock/infoutil_mock.go index 298597ece67..46dec6ac567 100644 --- a/pkg/infoutil/infoutilmock/infoutil_mock.go +++ b/pkg/infoutil/infoutilmock/infoutil_mock.go @@ -16,93 +16,50 @@ limitations under the License. */ +// Package infoutilmock provides a hand-rolled fake for the windowsInfoUtil +// interface used in tests. It replaces the previous gomock-generated mock so +// that nerdctl does not depend on go.uber.org/mock. package infoutilmock import ( - "reflect" - - "go.uber.org/mock/gomock" "golang.org/x/sys/windows" "golang.org/x/sys/windows/registry" ) -// MockWindowsInfoUtil is a mock of windowsInfoUtil interface -type MockWindowsInfoUtil struct { - ctrl *gomock.Controller - recorder *MockWindowsInfoUtilMockRecorder -} - -// MockWindowsInfoUtilMockRecorder is the mock recorder for MockWindowsInfoUtil -type MockWindowsInfoUtilMockRecorder struct { - mock *MockWindowsInfoUtil -} - -// NewMockWindowsInfoUtil creates a new mock instance -func NewMockWindowsInfoUtil(ctrl *gomock.Controller) *MockWindowsInfoUtil { - mock := &MockWindowsInfoUtil{ctrl: ctrl} - mock.recorder = &MockWindowsInfoUtilMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockWindowsInfoUtil) EXPECT() *MockWindowsInfoUtilMockRecorder { - return m.recorder -} - -// Create mocks the RtlGetVersion method of windowsInfoUtil -func (m *MockWindowsInfoUtil) RtlGetVersion() *windows.OsVersionInfoEx { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RtlGetVersion") - ret0, _ := ret[0].(*windows.OsVersionInfoEx) - return ret0 -} - -// Expected call of RtlGetVersion -func (m *MockWindowsInfoUtilMockRecorder) RtlGetVersion() *gomock.Call { - m.mock.ctrl.T.Helper() - return m.mock.ctrl.RecordCallWithMethodType( - m.mock, - "RtlGetVersion", - reflect.TypeOf((*MockWindowsInfoUtil)(nil).RtlGetVersion), - ) +// FakeWindowsInfoUtil is a configurable test double for the windowsInfoUtil +// interface. Tests assign the function fields to control behavior per call. +type FakeWindowsInfoUtil struct { + RtlGetVersionFunc func() *windows.OsVersionInfoEx + GetRegistryStringValueFunc func(key registry.Key, path string, name string) (string, error) + GetRegistryIntValueFunc func(key registry.Key, path string, name string) (int, error) } -// Create mocks the GetRegistryStringValue method of windowsInfoUtil -func (m *MockWindowsInfoUtil) GetRegistryStringValue(key registry.Key, path string, name string) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetRegistryStringValue", key, path, name) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 +// NewFakeWindowsInfoUtil returns an empty fake. Callers populate the function +// fields they need for a given test. +func NewFakeWindowsInfoUtil() *FakeWindowsInfoUtil { + return &FakeWindowsInfoUtil{} } -// Expected call of GetRegistryStringValue -func (m *MockWindowsInfoUtilMockRecorder) GetRegistryStringValue(key any, path any, name any) *gomock.Call { - m.mock.ctrl.T.Helper() - return m.mock.ctrl.RecordCallWithMethodType( - m.mock, - "GetRegistryStringValue", - reflect.TypeOf((*MockWindowsInfoUtil)(nil).GetRegistryStringValue), - key, path, name, - ) +// RtlGetVersion calls the configured function, or returns nil if unset. +func (f *FakeWindowsInfoUtil) RtlGetVersion() *windows.OsVersionInfoEx { + if f.RtlGetVersionFunc == nil { + return nil + } + return f.RtlGetVersionFunc() } -// Create mocks the GetRegistryIntValue method of windowsInfoUtil -func (m *MockWindowsInfoUtil) GetRegistryIntValue(key registry.Key, path string, name string) (int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetRegistryIntValue", key, path, name) - ret0, _ := ret[0].(int) - ret1, _ := ret[1].(error) - return ret0, ret1 +// GetRegistryStringValue calls the configured function, or returns ("", nil) if unset. +func (f *FakeWindowsInfoUtil) GetRegistryStringValue(key registry.Key, path string, name string) (string, error) { + if f.GetRegistryStringValueFunc == nil { + return "", nil + } + return f.GetRegistryStringValueFunc(key, path, name) } -// Expected call of GetRegistryIntValue -func (m *MockWindowsInfoUtilMockRecorder) GetRegistryIntValue(key any, path any, name any) *gomock.Call { - m.mock.ctrl.T.Helper() - return m.mock.ctrl.RecordCallWithMethodType( - m.mock, - "GetRegistryIntValue", - reflect.TypeOf((*MockWindowsInfoUtil)(nil).GetRegistryIntValue), - key, path, name, - ) +// GetRegistryIntValue calls the configured function, or returns (0, nil) if unset. +func (f *FakeWindowsInfoUtil) GetRegistryIntValue(key registry.Key, path string, name string) (int, error) { + if f.GetRegistryIntValueFunc == nil { + return 0, nil + } + return f.GetRegistryIntValueFunc(key, path, name) }