Skip to content

Commit

Permalink
Add mocks for all interfaces under pkg/nvml/mock
Browse files Browse the repository at this point in the history
We should eventually expand this package to include a unified mock server like
we have in the go-nvlib testing and mig-parted testing.

Signed-off-by: Kevin Klues <kklues@nvidia.com>
  • Loading branch information
klueska committed Apr 12, 2024
1 parent dcdd80e commit dd0a843
Show file tree
Hide file tree
Showing 11 changed files with 24,442 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gen/nvml/generateapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,13 @@ func generatePackageMethodsComment(input GeneratableInterfacePoperties) (string,
func generateInterfaceComment(input GeneratableInterfacePoperties) (string, error) {
commentFmt := []string{
"// %s represents the interface for the %s type.",
"//",
"//go:generate moq -out mock/%s.go -pkg mock . %s",
}

var signature strings.Builder
comment := strings.Join(commentFmt, "\n")
comment = fmt.Sprintf(comment, input.Interface, input.Type)
comment = fmt.Sprintf(comment, input.Interface, input.Type, strings.ToLower(input.Interface), input.Interface)
signature.WriteString(fmt.Sprintf("%s\n", comment))
return signature.String(), nil
}
Expand Down
105 changes: 105 additions & 0 deletions pkg/nvml/mock/computeinstance.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dd0a843

Please sign in to comment.