diff --git a/agent/go/.mockery.yaml b/agent/go/.mockery.yaml new file mode 100644 index 00000000..2e5b6cf9 --- /dev/null +++ b/agent/go/.mockery.yaml @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +dir: '{{.InterfaceDir}}/mock' +filename: "{{.InterfaceName}}.go" +template: testify +template-data: + unroll-variadic: true +packages: + github.com/NVIDIA/nodewright/agent/internal/config: + interfaces: + SchemaValidator: {} + github.com/NVIDIA/nodewright/agent/internal/history: + interfaces: + Store: {} + github.com/NVIDIA/nodewright/agent/internal/interrupts: + interfaces: + Interrupt: {} + github.com/NVIDIA/nodewright/agent/internal/step: + interfaces: + Step: {} diff --git a/agent/go/Makefile b/agent/go/Makefile index 3fee840e..82443a25 100644 --- a/agent/go/Makefile +++ b/agent/go/Makefile @@ -63,6 +63,11 @@ license-header-check: addlicense ## Fail if any agent Go source file is missing fmt: license-fmt ## Format go files and update license headers. $(GO) fmt ./... +.PHONY: generate-mocks +generate-mocks: mockery ## Generate interface mocks. + $(MOCKERY) --config .mockery.yaml + $(MAKE) fmt + .PHONY: vet vet: ## Run go vet against code. $(GO) vet ./... diff --git a/agent/go/deps.mk b/agent/go/deps.mk index d116207a..72f33c4d 100644 --- a/agent/go/deps.mk +++ b/agent/go/deps.mk @@ -20,6 +20,7 @@ GOLANGCI_LINT_VERSION ?= v2.12.2 GINKGO_VERSION ?= v2.32.0 +MOCKERY_VERSION ?= v3.7.0 ADDLICENSE_VERSION ?= v1.2.0 ## Location to install dependencies to @@ -29,10 +30,11 @@ $(LOCALBIN): GOLANGCI_LINT = $(LOCALBIN)/golangci-lint GINKGO = $(LOCALBIN)/ginkgo +MOCKERY = $(LOCALBIN)/mockery ADDLICENSE = $(LOCALBIN)/addlicense .PHONY: install-deps -install-deps: golangci-lint ginkgo addlicense ## Install all dependencies. +install-deps: golangci-lint ginkgo mockery addlicense ## Install all dependencies. .PHONY: golangci-lint golangci-lint: $(LOCALBIN) ## Download golangci-lint locally if necessary. @@ -47,6 +49,12 @@ ginkgo: $(LOCALBIN) ## Download ginkgo locally if necessary. && [ "$$($(GINKGO) version)" = "Ginkgo Version $(patsubst v%,%,$(GINKGO_VERSION))" ] \ || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION) +.PHONY: mockery +mockery: $(LOCALBIN) ## Download Mockery locally if necessary. + @test -x $(MOCKERY) \ + && [ "$$($(MOCKERY) version)" = "$(MOCKERY_VERSION)" ] \ + || GOBIN=$(LOCALBIN) go install github.com/vektra/mockery/v3@$(MOCKERY_VERSION) + .PHONY: addlicense addlicense: $(LOCALBIN) ## Download addlicense locally if necessary. test -s $(ADDLICENSE) || GOBIN=$(LOCALBIN) go install github.com/google/addlicense@$(ADDLICENSE_VERSION) diff --git a/agent/go/go.mod b/agent/go/go.mod index 6f1c89fa..7039af04 100644 --- a/agent/go/go.mod +++ b/agent/go/go.mod @@ -6,14 +6,18 @@ require ( github.com/onsi/ginkgo/v2 v2.32.0 github.com/onsi/gomega v1.42.1 github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 + github.com/stretchr/testify v1.11.1 ) require ( github.com/Masterminds/semver/v3 v3.4.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/mod v0.36.0 // indirect golang.org/x/net v0.56.0 // indirect @@ -21,4 +25,5 @@ require ( golang.org/x/sys v0.46.0 // indirect golang.org/x/text v0.38.0 // indirect golang.org/x/tools v0.45.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/agent/go/go.sum b/agent/go/go.sum index ab87d9f4..979dcc49 100644 --- a/agent/go/go.sum +++ b/agent/go/go.sum @@ -40,8 +40,10 @@ github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28= github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= diff --git a/agent/go/internal/config/mock/SchemaValidator.go b/agent/go/internal/config/mock/SchemaValidator.go new file mode 100644 index 00000000..543cc13e --- /dev/null +++ b/agent/go/internal/config/mock/SchemaValidator.go @@ -0,0 +1,112 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: testify + +package config + +import ( + "github.com/NVIDIA/nodewright/agent/internal/schema" + mock "github.com/stretchr/testify/mock" +) + +// NewMockSchemaValidator creates a new instance of MockSchemaValidator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockSchemaValidator(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSchemaValidator { + mock := &MockSchemaValidator{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} + +// MockSchemaValidator is an autogenerated mock type for the SchemaValidator type +type MockSchemaValidator struct { + mock.Mock +} + +type MockSchemaValidator_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSchemaValidator) EXPECT() *MockSchemaValidator_Expecter { + return &MockSchemaValidator_Expecter{mock: &_m.Mock} +} + +// Validate provides a mock function for the type MockSchemaValidator +func (_mock *MockSchemaValidator) Validate(data []byte, v schema.SchemaVersion) error { + ret := _mock.Called(data, v) + + if len(ret) == 0 { + panic("no return value specified for Validate") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func([]byte, schema.SchemaVersion) error); ok { + r0 = returnFunc(data, v) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockSchemaValidator_Validate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Validate' +type MockSchemaValidator_Validate_Call struct { + *mock.Call +} + +// Validate is a helper method to define mock.On call +// - data []byte +// - v schema.SchemaVersion +func (_e *MockSchemaValidator_Expecter) Validate(data interface{}, v interface{}) *MockSchemaValidator_Validate_Call { + return &MockSchemaValidator_Validate_Call{Call: _e.mock.On("Validate", data, v)} +} + +func (_c *MockSchemaValidator_Validate_Call) Run(run func(data []byte, v schema.SchemaVersion)) *MockSchemaValidator_Validate_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 []byte + if args[0] != nil { + arg0 = args[0].([]byte) + } + var arg1 schema.SchemaVersion + if args[1] != nil { + arg1 = args[1].(schema.SchemaVersion) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockSchemaValidator_Validate_Call) Return(err error) *MockSchemaValidator_Validate_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockSchemaValidator_Validate_Call) RunAndReturn(run func(data []byte, v schema.SchemaVersion) error) *MockSchemaValidator_Validate_Call { + _c.Call.Return(run) + return _c +} diff --git a/agent/go/internal/config/validate_test.go b/agent/go/internal/config/validate_test.go index a02a2d32..8db40ce6 100644 --- a/agent/go/internal/config/validate_test.go +++ b/agent/go/internal/config/validate_test.go @@ -26,6 +26,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + configmock "github.com/NVIDIA/nodewright/agent/internal/config/mock" "github.com/NVIDIA/nodewright/agent/internal/schema" "github.com/NVIDIA/nodewright/agent/internal/stage" "github.com/NVIDIA/nodewright/agent/internal/step" @@ -169,17 +170,14 @@ var _ = Describe("validateModes", func() { var _ = Describe("Loader schema-validation seam", func() { It("surfaces the injected validator's error without parsing the document", func() { sentinel := errors.New("boom from fake validator") - loader := &Loader{validator: fakeValidator{err: sentinel}} + validator := configmock.NewMockSchemaValidator(GinkgoT()) + validator.EXPECT(). + Validate([]byte(validConfigJSON), schema.V1). + Return(sentinel). + Once() + loader := &Loader{validator: validator} _, err := loader.Load([]byte(validConfigJSON), GinkgoT().TempDir(), nil) Expect(err).To(MatchError(sentinel)) }) }) - -// fakeValidator is a SchemaValidator stand-in that returns a fixed result, -// proving Loader depends on the interface rather than the embedded schemas. -type fakeValidator struct { - err error -} - -func (f fakeValidator) Validate(_ []byte, _ schema.SchemaVersion) error { return f.err } diff --git a/agent/go/internal/history/mock/Store.go b/agent/go/internal/history/mock/Store.go new file mode 100644 index 00000000..5ffa4bd7 --- /dev/null +++ b/agent/go/internal/history/mock/Store.go @@ -0,0 +1,168 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: testify + +package history + +import ( + "time" + + "github.com/NVIDIA/nodewright/agent/internal/history" + "github.com/NVIDIA/nodewright/agent/internal/stage" + mock "github.com/stretchr/testify/mock" +) + +// NewMockStore creates a new instance of MockStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockStore(t interface { + mock.TestingT + Cleanup(func()) +}) *MockStore { + mock := &MockStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} + +// MockStore is an autogenerated mock type for the Store type +type MockStore struct { + mock.Mock +} + +type MockStore_Expecter struct { + mock *mock.Mock +} + +func (_m *MockStore) EXPECT() *MockStore_Expecter { + return &MockStore_Expecter{mock: &_m.Mock} +} + +// Read provides a mock function for the type MockStore +func (_mock *MockStore) Read() (history.Versions, error) { + ret := _mock.Called() + + if len(ret) == 0 { + panic("no return value specified for Read") + } + + var r0 history.Versions + var r1 error + if returnFunc, ok := ret.Get(0).(func() (history.Versions, error)); ok { + return returnFunc() + } + if returnFunc, ok := ret.Get(0).(func() history.Versions); ok { + r0 = returnFunc() + } else { + r0 = ret.Get(0).(history.Versions) + } + if returnFunc, ok := ret.Get(1).(func() error); ok { + r1 = returnFunc() + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockStore_Read_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Read' +type MockStore_Read_Call struct { + *mock.Call +} + +// Read is a helper method to define mock.On call +func (_e *MockStore_Expecter) Read() *MockStore_Read_Call { + return &MockStore_Read_Call{Call: _e.mock.On("Read")} +} + +func (_c *MockStore_Read_Call) Run(run func()) *MockStore_Read_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockStore_Read_Call) Return(versions history.Versions, err error) *MockStore_Read_Call { + _c.Call.Return(versions, err) + return _c +} + +func (_c *MockStore_Read_Call) RunAndReturn(run func() (history.Versions, error)) *MockStore_Read_Call { + _c.Call.Return(run) + return _c +} + +// Record provides a mock function for the type MockStore +func (_mock *MockStore) Record(completedStage stage.Stage, at time.Time) error { + ret := _mock.Called(completedStage, at) + + if len(ret) == 0 { + panic("no return value specified for Record") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(stage.Stage, time.Time) error); ok { + r0 = returnFunc(completedStage, at) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockStore_Record_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Record' +type MockStore_Record_Call struct { + *mock.Call +} + +// Record is a helper method to define mock.On call +// - completedStage stage.Stage +// - at time.Time +func (_e *MockStore_Expecter) Record(completedStage interface{}, at interface{}) *MockStore_Record_Call { + return &MockStore_Record_Call{Call: _e.mock.On("Record", completedStage, at)} +} + +func (_c *MockStore_Record_Call) Run(run func(completedStage stage.Stage, at time.Time)) *MockStore_Record_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 stage.Stage + if args[0] != nil { + arg0 = args[0].(stage.Stage) + } + var arg1 time.Time + if args[1] != nil { + arg1 = args[1].(time.Time) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockStore_Record_Call) Return(err error) *MockStore_Record_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockStore_Record_Call) RunAndReturn(run func(completedStage stage.Stage, at time.Time) error) *MockStore_Record_Call { + _c.Call.Return(run) + return _c +} diff --git a/agent/go/internal/interrupts/mock/Interrupt.go b/agent/go/internal/interrupts/mock/Interrupt.go new file mode 100644 index 00000000..82e8b872 --- /dev/null +++ b/agent/go/internal/interrupts/mock/Interrupt.go @@ -0,0 +1,223 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: testify + +package interrupts + +import ( + "context" + + "github.com/NVIDIA/nodewright/agent/internal/execution" + "github.com/NVIDIA/nodewright/agent/internal/interrupts" + mock "github.com/stretchr/testify/mock" +) + +// NewMockInterrupt creates a new instance of MockInterrupt. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockInterrupt(t interface { + mock.TestingT + Cleanup(func()) +}) *MockInterrupt { + mock := &MockInterrupt{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} + +// MockInterrupt is an autogenerated mock type for the Interrupt type +type MockInterrupt struct { + mock.Mock +} + +type MockInterrupt_Expecter struct { + mock *mock.Mock +} + +func (_m *MockInterrupt) EXPECT() *MockInterrupt_Expecter { + return &MockInterrupt_Expecter{mock: &_m.Mock} +} + +// Run provides a mock function for the type MockInterrupt +func (_mock *MockInterrupt) Run(context1 context.Context, config execution.Config) (execution.Status, error) { + ret := _mock.Called(context1, config) + + if len(ret) == 0 { + panic("no return value specified for Run") + } + + var r0 execution.Status + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, execution.Config) (execution.Status, error)); ok { + return returnFunc(context1, config) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, execution.Config) execution.Status); ok { + r0 = returnFunc(context1, config) + } else { + r0 = ret.Get(0).(execution.Status) + } + if returnFunc, ok := ret.Get(1).(func(context.Context, execution.Config) error); ok { + r1 = returnFunc(context1, config) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockInterrupt_Run_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Run' +type MockInterrupt_Run_Call struct { + *mock.Call +} + +// Run is a helper method to define mock.On call +// - context1 context.Context +// - config execution.Config +func (_e *MockInterrupt_Expecter) Run(context1 interface{}, config interface{}) *MockInterrupt_Run_Call { + return &MockInterrupt_Run_Call{Call: _e.mock.On("Run", context1, config)} +} + +func (_c *MockInterrupt_Run_Call) Run(run func(context1 context.Context, config execution.Config)) *MockInterrupt_Run_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 execution.Config + if args[1] != nil { + arg1 = args[1].(execution.Config) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockInterrupt_Run_Call) Return(status execution.Status, err error) *MockInterrupt_Run_Call { + _c.Call.Return(status, err) + return _c +} + +func (_c *MockInterrupt_Run_Call) RunAndReturn(run func(context1 context.Context, config execution.Config) (execution.Status, error)) *MockInterrupt_Run_Call { + _c.Call.Return(run) + return _c +} + +// Serialize provides a mock function for the type MockInterrupt +func (_mock *MockInterrupt) Serialize() ([]byte, error) { + ret := _mock.Called() + + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + + var r0 []byte + var r1 error + if returnFunc, ok := ret.Get(0).(func() ([]byte, error)); ok { + return returnFunc() + } + if returnFunc, ok := ret.Get(0).(func() []byte); ok { + r0 = returnFunc() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + if returnFunc, ok := ret.Get(1).(func() error); ok { + r1 = returnFunc() + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockInterrupt_Serialize_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Serialize' +type MockInterrupt_Serialize_Call struct { + *mock.Call +} + +// Serialize is a helper method to define mock.On call +func (_e *MockInterrupt_Expecter) Serialize() *MockInterrupt_Serialize_Call { + return &MockInterrupt_Serialize_Call{Call: _e.mock.On("Serialize")} +} + +func (_c *MockInterrupt_Serialize_Call) Run(run func()) *MockInterrupt_Serialize_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockInterrupt_Serialize_Call) Return(bytes []byte, err error) *MockInterrupt_Serialize_Call { + _c.Call.Return(bytes, err) + return _c +} + +func (_c *MockInterrupt_Serialize_Call) RunAndReturn(run func() ([]byte, error)) *MockInterrupt_Serialize_Call { + _c.Call.Return(run) + return _c +} + +// Type provides a mock function for the type MockInterrupt +func (_mock *MockInterrupt) Type() interrupts.InterruptType { + ret := _mock.Called() + + if len(ret) == 0 { + panic("no return value specified for Type") + } + + var r0 interrupts.InterruptType + if returnFunc, ok := ret.Get(0).(func() interrupts.InterruptType); ok { + r0 = returnFunc() + } else { + r0 = ret.Get(0).(interrupts.InterruptType) + } + return r0 +} + +// MockInterrupt_Type_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Type' +type MockInterrupt_Type_Call struct { + *mock.Call +} + +// Type is a helper method to define mock.On call +func (_e *MockInterrupt_Expecter) Type() *MockInterrupt_Type_Call { + return &MockInterrupt_Type_Call{Call: _e.mock.On("Type")} +} + +func (_c *MockInterrupt_Type_Call) Run(run func()) *MockInterrupt_Type_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockInterrupt_Type_Call) Return(interruptType interrupts.InterruptType) *MockInterrupt_Type_Call { + _c.Call.Return(interruptType) + return _c +} + +func (_c *MockInterrupt_Type_Call) RunAndReturn(run func() interrupts.InterruptType) *MockInterrupt_Type_Call { + _c.Call.Return(run) + return _c +} diff --git a/agent/go/internal/step/mock/Step.go b/agent/go/internal/step/mock/Step.go new file mode 100644 index 00000000..c76dd2ca --- /dev/null +++ b/agent/go/internal/step/mock/Step.go @@ -0,0 +1,379 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: testify + +package step + +import ( + "context" + + "github.com/NVIDIA/nodewright/agent/internal/execution" + "github.com/NVIDIA/nodewright/agent/internal/step" + mock "github.com/stretchr/testify/mock" +) + +// NewMockStep creates a new instance of MockStep. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockStep(t interface { + mock.TestingT + Cleanup(func()) +}) *MockStep { + mock := &MockStep{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} + +// MockStep is an autogenerated mock type for the Step type +type MockStep struct { + mock.Mock +} + +type MockStep_Expecter struct { + mock *mock.Mock +} + +func (_m *MockStep) EXPECT() *MockStep_Expecter { + return &MockStep_Expecter{mock: &_m.Mock} +} + +// Encode provides a mock function for the type MockStep +func (_mock *MockStep) Encode() ([]byte, error) { + ret := _mock.Called() + + if len(ret) == 0 { + panic("no return value specified for Encode") + } + + var r0 []byte + var r1 error + if returnFunc, ok := ret.Get(0).(func() ([]byte, error)); ok { + return returnFunc() + } + if returnFunc, ok := ret.Get(0).(func() []byte); ok { + r0 = returnFunc() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + if returnFunc, ok := ret.Get(1).(func() error); ok { + r1 = returnFunc() + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockStep_Encode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Encode' +type MockStep_Encode_Call struct { + *mock.Call +} + +// Encode is a helper method to define mock.On call +func (_e *MockStep_Expecter) Encode() *MockStep_Encode_Call { + return &MockStep_Encode_Call{Call: _e.mock.On("Encode")} +} + +func (_c *MockStep_Encode_Call) Run(run func()) *MockStep_Encode_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockStep_Encode_Call) Return(bytes []byte, err error) *MockStep_Encode_Call { + _c.Call.Return(bytes, err) + return _c +} + +func (_c *MockStep_Encode_Call) RunAndReturn(run func() ([]byte, error)) *MockStep_Encode_Call { + _c.Call.Return(run) + return _c +} + +// Fingerprint provides a mock function for the type MockStep +func (_mock *MockStep) Fingerprint() (string, error) { + ret := _mock.Called() + + if len(ret) == 0 { + panic("no return value specified for Fingerprint") + } + + var r0 string + var r1 error + if returnFunc, ok := ret.Get(0).(func() (string, error)); ok { + return returnFunc() + } + if returnFunc, ok := ret.Get(0).(func() string); ok { + r0 = returnFunc() + } else { + r0 = ret.Get(0).(string) + } + if returnFunc, ok := ret.Get(1).(func() error); ok { + r1 = returnFunc() + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockStep_Fingerprint_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Fingerprint' +type MockStep_Fingerprint_Call struct { + *mock.Call +} + +// Fingerprint is a helper method to define mock.On call +func (_e *MockStep_Expecter) Fingerprint() *MockStep_Fingerprint_Call { + return &MockStep_Fingerprint_Call{Call: _e.mock.On("Fingerprint")} +} + +func (_c *MockStep_Fingerprint_Call) Run(run func()) *MockStep_Fingerprint_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockStep_Fingerprint_Call) Return(s string, err error) *MockStep_Fingerprint_Call { + _c.Call.Return(s, err) + return _c +} + +func (_c *MockStep_Fingerprint_Call) RunAndReturn(run func() (string, error)) *MockStep_Fingerprint_Call { + _c.Call.Return(run) + return _c +} + +// Idempotence provides a mock function for the type MockStep +func (_mock *MockStep) Idempotence() step.Idempotence { + ret := _mock.Called() + + if len(ret) == 0 { + panic("no return value specified for Idempotence") + } + + var r0 step.Idempotence + if returnFunc, ok := ret.Get(0).(func() step.Idempotence); ok { + r0 = returnFunc() + } else { + r0 = ret.Get(0).(step.Idempotence) + } + return r0 +} + +// MockStep_Idempotence_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Idempotence' +type MockStep_Idempotence_Call struct { + *mock.Call +} + +// Idempotence is a helper method to define mock.On call +func (_e *MockStep_Expecter) Idempotence() *MockStep_Idempotence_Call { + return &MockStep_Idempotence_Call{Call: _e.mock.On("Idempotence")} +} + +func (_c *MockStep_Idempotence_Call) Run(run func()) *MockStep_Idempotence_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockStep_Idempotence_Call) Return(idempotence step.Idempotence) *MockStep_Idempotence_Call { + _c.Call.Return(idempotence) + return _c +} + +func (_c *MockStep_Idempotence_Call) RunAndReturn(run func() step.Idempotence) *MockStep_Idempotence_Call { + _c.Call.Return(run) + return _c +} + +// Path provides a mock function for the type MockStep +func (_mock *MockStep) Path() string { + ret := _mock.Called() + + if len(ret) == 0 { + panic("no return value specified for Path") + } + + var r0 string + if returnFunc, ok := ret.Get(0).(func() string); ok { + r0 = returnFunc() + } else { + r0 = ret.Get(0).(string) + } + return r0 +} + +// MockStep_Path_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Path' +type MockStep_Path_Call struct { + *mock.Call +} + +// Path is a helper method to define mock.On call +func (_e *MockStep_Expecter) Path() *MockStep_Path_Call { + return &MockStep_Path_Call{Call: _e.mock.On("Path")} +} + +func (_c *MockStep_Path_Call) Run(run func()) *MockStep_Path_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockStep_Path_Call) Return(s string) *MockStep_Path_Call { + _c.Call.Return(s) + return _c +} + +func (_c *MockStep_Path_Call) RunAndReturn(run func() string) *MockStep_Path_Call { + _c.Call.Return(run) + return _c +} + +// Run provides a mock function for the type MockStep +func (_mock *MockStep) Run(context1 context.Context, config execution.Config) (execution.Status, error) { + ret := _mock.Called(context1, config) + + if len(ret) == 0 { + panic("no return value specified for Run") + } + + var r0 execution.Status + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, execution.Config) (execution.Status, error)); ok { + return returnFunc(context1, config) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, execution.Config) execution.Status); ok { + r0 = returnFunc(context1, config) + } else { + r0 = ret.Get(0).(execution.Status) + } + if returnFunc, ok := ret.Get(1).(func(context.Context, execution.Config) error); ok { + r1 = returnFunc(context1, config) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockStep_Run_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Run' +type MockStep_Run_Call struct { + *mock.Call +} + +// Run is a helper method to define mock.On call +// - context1 context.Context +// - config execution.Config +func (_e *MockStep_Expecter) Run(context1 interface{}, config interface{}) *MockStep_Run_Call { + return &MockStep_Run_Call{Call: _e.mock.On("Run", context1, config)} +} + +func (_c *MockStep_Run_Call) Run(run func(context1 context.Context, config execution.Config)) *MockStep_Run_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 execution.Config + if args[1] != nil { + arg1 = args[1].(execution.Config) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockStep_Run_Call) Return(status execution.Status, err error) *MockStep_Run_Call { + _c.Call.Return(status, err) + return _c +} + +func (_c *MockStep_Run_Call) RunAndReturn(run func(context1 context.Context, config execution.Config) (execution.Status, error)) *MockStep_Run_Call { + _c.Call.Return(run) + return _c +} + +// WithVersions provides a mock function for the type MockStep +func (_mock *MockStep) WithVersions(previous string, current string) step.Step { + ret := _mock.Called(previous, current) + + if len(ret) == 0 { + panic("no return value specified for WithVersions") + } + + var r0 step.Step + if returnFunc, ok := ret.Get(0).(func(string, string) step.Step); ok { + r0 = returnFunc(previous, current) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(step.Step) + } + } + return r0 +} + +// MockStep_WithVersions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WithVersions' +type MockStep_WithVersions_Call struct { + *mock.Call +} + +// WithVersions is a helper method to define mock.On call +// - previous string +// - current string +func (_e *MockStep_Expecter) WithVersions(previous interface{}, current interface{}) *MockStep_WithVersions_Call { + return &MockStep_WithVersions_Call{Call: _e.mock.On("WithVersions", previous, current)} +} + +func (_c *MockStep_WithVersions_Call) Run(run func(previous string, current string)) *MockStep_WithVersions_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 string + if args[0] != nil { + arg0 = args[0].(string) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockStep_WithVersions_Call) Return(step1 step.Step) *MockStep_WithVersions_Call { + _c.Call.Return(step1) + return _c +} + +func (_c *MockStep_WithVersions_Call) RunAndReturn(run func(previous string, current string) step.Step) *MockStep_WithVersions_Call { + _c.Call.Return(run) + return _c +}