-
Notifications
You must be signed in to change notification settings - Fork 77
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
Added automatically generated acceptance tests for CLI commands #2501
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,5 @@ | |||
|
|||
>>> errcode [CLI] query-history list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found an actual issue, will fix
@@ -24,7 +24,7 @@ func New() *cobra.Command { | |||
Short: `The Serving Endpoints API allows you to create, update, and delete model serving endpoints.`, | |||
Long: `The Serving Endpoints API allows you to create, update, and delete model | |||
serving endpoints. | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What caused this diff? Seems like something we should revert.
@@ -134,6 +260,3 @@ cmd/workspace/warehouses/warehouses.go linguist-generated=true | |||
cmd/workspace/workspace-bindings/workspace-bindings.go linguist-generated=true | |||
cmd/workspace/workspace-conf/workspace-conf.go linguist-generated=true | |||
cmd/workspace/workspace/workspace.go linguist-generated=true | |||
bundle/internal/tf/schema/\*.go linguist-generated=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not go away. Seems unintended.
@@ -1,9 +1,11 @@ | |||
{ | |||
"mode": "cli_legacy", | |||
"api_changelog": true, | |||
"formatter": "go run golang.org/x/tools/cmd/goimports@latest -w $FILENAMES && go fmt ./...", | |||
"formatter": "go run golang.org/x/tools/cmd/goimports@latest -w cmd && go fmt ./...", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, but we can also remove go fmt ./...
"services": { | ||
".codegen/service.go.tmpl": "cmd/{{if .IsAccounts}}account{{else}}workspace{{end}}/{{(.TrimPrefix \"account\").KebabName}}/{{(.TrimPrefix \"account\").KebabName}}.go" | ||
".codegen/service.go.tmpl": "cmd/{{if .IsAccounts}}account{{else}}workspace{{end}}/{{(.TrimPrefix \"account\").KebabName}}/{{(.TrimPrefix \"account\").KebabName}}.go", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, but seems like .KebabName
no longer includes an account or a workspace prefix. Can we simply this?
# Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. | ||
{{- $excludes := | ||
list | ||
"command-execution" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation, spaces vs tabs.
{{- $generated := false -}} | ||
{{- $supportedMethods := list "get" "list" "list-pipelines" }} | ||
{{- range .Methods}} | ||
{{- if in $supportedMethods .KebabName}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can inline skipThisFile
and remove $generated
by using a negative predicate:
{{- if in $supportedMethods .KebabName}} | |
{{- if not (in $supportedMethods .KebabName) }} |
{{- $generated = true }} | ||
|
||
[[Server]] | ||
Pattern = "{{.Verb}} {{replaceAll "2.2" "2.1" .Path}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this replacement?
{{- if in $supportedMethods .KebabName}} | ||
{{- $generated = true }} | ||
|
||
[[Server]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of defining a server definition for every command, should we generate a FakeWorkspace, extending the idea in libs/testserver/fake_workspace.go
to support stubs for all API calls?
The advantage of fake workspace is eventually it'll be possible to do more CRUD-like autogenerated tests as well. It's also a more general interface, which can be useful in other contexts since it's basically a local simulation of a Databricks workspace.
Writing the server in Go also allows us handle all sorts of API paths and support CREATE, DELETE etc since generating the server stubs in Go is a lot more powerful that generating them in toml
.
## Changes Fixed `Error: template: command:1:8: executing "command" at <.>: range can't iterate over` for query-history list command ## Why `query-history list` command has an override to use a different output template for list command. This template got outdated comparing to underlying API response structure and hence led to the error above. it was found by automatically generated tests here: #2501 ## Tests Added acceptance test
Changes
Added automatically generated acceptance tests for CLI commands.
Only List and Get commands are supported at the moment
dashboards
andqueries-legacy
are skipped for now as their list implementation stops only when API returns no results which acceptance test stubs do not support yetWhy
It helps to make sure that our CLI commands are generated and working correctly when CLI is regenerated. It is especially important for commands with template overrides where template might get out of date with SDK and API changes
It also highlights easier when there are breaking changes to CLI commands as they will be visible in the change of test
script
for corresponding command