-
Notifications
You must be signed in to change notification settings - Fork 21
test(agent): add generated interface mocks #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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: {} |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |||||||
|
|
||||||||
| GOLANGCI_LINT_VERSION ?= v2.12.2 | ||||||||
| GINKGO_VERSION ?= v2.32.0 | ||||||||
| MOCKERY_VERSION ?= v3.7.0 | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
printf '%s\n' '--- agent/go/deps.mk ---'
cat -n agent/go/deps.mk
printf '%s\n' '--- Makefile and mockery references ---'
rg -n -C 4 'MOCKERY_VERSION|mockery|generate-mocks' agent/go --glob '!*vendor*'
printf '%s\n' '--- repository metadata ---'
rg -n 'mockery' .github Makefile* agent/go 2>/dev/null || trueRepository: NVIDIA/nodewright Length of output: 9434 🌐 Web query:
💡 Result: The issue where setting the MOCKERY_VERSION environment variable causes Mockery v3 to fail is a documented, known behavior [1][2][3]. Mockery uses the Viper library for configuration management [1][3]. Viper is configured to automatically detect and map environment variables that align with Mockery's internal configuration structure [3]. Because Mockery has an internal configuration setting named version, Viper automatically maps the MOCKERY_VERSION environment variable to this setting [1][2]. When you set MOCKERY_VERSION (for example, in a Dockerfile or CI environment), Mockery attempts to parse that value into its internal version configuration [3]. Since this internal configuration expects a boolean value (e.g., true/false), providing a version string like 2.5.1 or 3.6.4 results in a parsing error and prevents Mockery from executing [3]. The official resolution is to rename the environment variable to something other than MOCKERY_VERSION (e.g., MOCKERY_INSTALL_VERSION) to avoid this collision [1][3]. Citations:
🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- agent/go/Makefile ---'
cat -n agent/go/Makefile | sed -n '1,75p'
printf '%s\n' '--- GNU Make export behavior: command-line override ---'
make -f - MOCKERY_VERSION=v3.7.0 <<'MAKE'
.PHONY: probe
probe:
`@env` | grep '^MOCKERY_VERSION=' || true
MAKE
printf '%s\n' '--- GNU Make export behavior: command-line override plus unexport ---'
make -f - MOCKERY_VERSION=v3.7.0 <<'MAKE'
MOCKERY_VERSION ?= v3.7.0
unexport MOCKERY_VERSION
.PHONY: probe
probe:
`@if` env | grep '^MOCKERY_VERSION='; then exit 1; else echo 'MOCKERY_VERSION not exported'; fi
MAKE
printf '%s\n' '--- GNU Make export behavior: environment override plus unexport ---'
MOCKERY_VERSION=v3.7.0 make -f - <<'MAKE'
MOCKERY_VERSION ?= v3.7.0
unexport MOCKERY_VERSION
.PHONY: probe
probe:
`@if` env | grep '^MOCKERY_VERSION='; then exit 1; else echo 'MOCKERY_VERSION not exported'; fi
MAKERepository: NVIDIA/nodewright Length of output: 3782 Keep Mockery v3 maps this environment variable to its boolean Proposed fix MOCKERY_VERSION ?= v3.7.0
+unexport MOCKERY_VERSION📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| 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) | ||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.