-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat: cli create test command #609
Conversation
@@ -23,7 +23,6 @@ components: | |||
$ref: "#/components/schemas/HTTPHeader" | |||
body: | |||
type: string | |||
format: byte |
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.
Basically, this means the body
should be in base64
format. But this is not true. I removed this so prism could add the correct validations to the requests I'm sending.
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.
good catch
- http.status = 200 | ||
- selector: span[span.name = "consume message from queue"]:last span[span.name = "save pokemon on database"] | ||
assertions: | ||
- db.repository.operation = "create" |
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.
There are some details in the syntax here. When defining an assertion, the value must be quoted if it is a string. Right now we support int
, double
, and string
values.
@@ -0,0 +1,33 @@ | |||
name: POST import pokemon | |||
description: Import a pokemon using its ID |
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.
do we have a description
in the UI?
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.
No, we don't. We have this field in the openapi spec though. We probably can remove it.
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.
Looking good! really nice code. I left some very minor nit comments, but this is ready to go!
type: raw | ||
raw: '{ "id": 52 }' | ||
testDefinition: | ||
- selector: span[span.name = "POST /pokemon/import"] |
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.
I really like this format, super clear and concise
cli/file/definition_test.go
Outdated
ShouldSucceed bool | ||
}{ | ||
{ | ||
Name: "Should parse valid definition file", |
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.
nit: when you get a fail message form go test
, it replaces spaces with _
. I like to use names that I can also search all files
for. In this case, the go test error would look like TestLoadDefinition/Should_parse_valid_definition_file
, and if I search for that, I won't have a match
cli/file/definition.go
Outdated
func LoadDefinition(file string) (definition.Test, error) { | ||
fileBytes, err := os.ReadFile(file) | ||
if err != nil { | ||
return definition.Test{}, fmt.Errorf("could not read file %s: %w", file, err) |
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.
nit: a more specific message could help debugging, like could not read test definition file...
} | ||
|
||
value := assertionParserObject.Value | ||
if value[0:1] == "\"" { |
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.
maybe this looks easier to read?
if value[0:1] == "\"" { | |
if value[0:1] == `"` { |
b8c9011
to
d8887b6
Compare
Applied all changes! Thanks for the review @schoren |
This PR adds the command
tracetest test run --definition file.yml
. Right now it just creates the test if it doesn't exist yet. I'll open more PRs to add the functionality for waiting until the result is finished and to update an existing test.Other than the run command itself, it also introduces the text format specified in #160.
Loom video explaining it: https://www.loom.com/share/f738c2c1ef8e4500a358b76fa7ad1e63
Checklist