-
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): Allow user to reference protobuf file path on Test yaml from CLI #2620
Conversation
// Given I am a Tracetest CLI user | ||
// And I have my server recently created | ||
// And the datasource is already set | ||
|
||
// When I try to run a test with a gRPC trigger with embedded protobuf | ||
// Then it should pass | ||
testFile := env.GetTestResourcePath(t, "grpc-trigger-embedded-protobuf") | ||
|
||
command := fmt.Sprintf("test run -w -d %s", testFile) | ||
result := tracetestcli.Exec(t, command, tracetestcli.WithCLIConfig(cliConfig)) | ||
helpers.RequireExitCodeEqual(t, result, 0) | ||
require.Contains(result.StdOut, "✔ It calls Pokeshop correctly") // checks if the assertion was succeeded | ||
|
||
// When I try to run a test with a gRPC trigger with a reference to a protobuf file | ||
// Then it should pass | ||
testFile = env.GetTestResourcePath(t, "grpc-trigger-reference-protobuf") | ||
|
||
command = fmt.Sprintf("test run -w -d %s", testFile) | ||
result = tracetestcli.Exec(t, command, tracetestcli.WithCLIConfig(cliConfig)) | ||
helpers.RequireExitCodeEqual(t, result, 0) | ||
require.Contains(result.StdOut, "✔ It calls Pokeshop correctly") // checks if the assertion was succeeded |
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 it's worth having two t.Run here?
// Given I am a Tracetest CLI user | |
// And I have my server recently created | |
// And the datasource is already set | |
// When I try to run a test with a gRPC trigger with embedded protobuf | |
// Then it should pass | |
testFile := env.GetTestResourcePath(t, "grpc-trigger-embedded-protobuf") | |
command := fmt.Sprintf("test run -w -d %s", testFile) | |
result := tracetestcli.Exec(t, command, tracetestcli.WithCLIConfig(cliConfig)) | |
helpers.RequireExitCodeEqual(t, result, 0) | |
require.Contains(result.StdOut, "✔ It calls Pokeshop correctly") // checks if the assertion was succeeded | |
// When I try to run a test with a gRPC trigger with a reference to a protobuf file | |
// Then it should pass | |
testFile = env.GetTestResourcePath(t, "grpc-trigger-reference-protobuf") | |
command = fmt.Sprintf("test run -w -d %s", testFile) | |
result = tracetestcli.Exec(t, command, tracetestcli.WithCLIConfig(cliConfig)) | |
helpers.RequireExitCodeEqual(t, result, 0) | |
require.Contains(result.StdOut, "✔ It calls Pokeshop correctly") // checks if the assertion was succeeded | |
// Given I am a Tracetest CLI user | |
// And I have my server recently created | |
// And the datasource is already set | |
t.Run("should pass when using an embedded protobuf string in the test", func(t *testing.,T) { | |
// When I try to run a test with a gRPC trigger with embedded protobuf | |
// Then it should pass | |
testFile := env.GetTestResourcePath(t, "grpc-trigger-embedded-protobuf") | |
command := fmt.Sprintf("test run -w -d %s", testFile) | |
result := tracetestcli.Exec(t, command, tracetestcli.WithCLIConfig(cliConfig)) | |
helpers.RequireExitCodeEqual(t, result, 0) | |
require.Contains(result.StdOut, "✔ It calls Pokeshop correctly") // checks if the assertion was succeeded | |
}) | |
t.Run("should pass when referencing a protobuf file in the test", func(t *testing.T) { | |
// When I try to run a test with a gRPC trigger with a reference to a protobuf file | |
// Then it should pass | |
testFile = env.GetTestResourcePath(t, "grpc-trigger-reference-protobuf") | |
command = fmt.Sprintf("test run -w -d %s", testFile) | |
result = tracetestcli.Exec(t, command, tracetestcli.WithCLIConfig(cliConfig)) | |
helpers.RequireExitCodeEqual(t, result, 0) | |
require.Contains(result.StdOut, "✔ It calls Pokeshop correctly") // checks if the assertion was succeeded | |
}) |
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.
It's worth it! I'm updating this test.
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.
Looks good, only one suggestion, but it's optional
…om CLI (#2620) * Adding grpc e2e test * Updating tests * Adding feature of read protobuf file from path and injecting it on gRPC trigger * Adding validation to the test * Adding PR suggestion
This PR allows a user to refer a single proto file path in a Test YAML instead of embedding the entire proto file.
Loom: https://www.loom.com/share/cb2f19a45f01454ca321be96d7c3f2dc
Changes
Fixes
Checklist