Skip to content
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

Merged
merged 5 commits into from
May 31, 2023

Conversation

danielbdias
Copy link
Contributor

@danielbdias danielbdias commented May 31, 2023

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

  • Update CLI to read proto file and injecting it on tests
  • Add e2e test to validate scenario
  • Updated e2e capabilities to create test environments with APIs and DataStores already set

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@danielbdias danielbdias changed the title Add/proto file read in grpc trigger chore(cli): Allow user to reference protobuf file path on Test yaml from CLI May 31, 2023
@danielbdias danielbdias changed the title chore(cli): Allow user to reference protobuf file path on Test yaml from CLI feat(cli): Allow user to reference protobuf file path on Test yaml from CLI May 31, 2023
@danielbdias danielbdias marked this pull request as ready for review May 31, 2023 02:30
Comment on lines 23 to 43
// 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
Copy link
Member

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?

Suggested change
// 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
})

Copy link
Contributor Author

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.

Copy link
Member

@mathnogueira mathnogueira left a 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

@danielbdias danielbdias merged commit ab6d0a4 into main May 31, 2023
@danielbdias danielbdias deleted the add/proto-file-read-in-grpc-trigger branch May 31, 2023 15:12
schoren pushed a commit that referenced this pull request Jun 5, 2023
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants