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

DXCDT-386: Expand logs test cases #663

Merged
merged 3 commits into from
Mar 8, 2023
Merged

Conversation

sergiught
Copy link
Contributor

@sergiught sergiught commented Mar 7, 2023

🔧 Changes

Expands the test cases for the logs command and its relative subcommands and also fixes raised bugs. More in the comments down below.

📚 References

🔬 Testing

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@sergiught sergiught force-pushed the DXCDT-386-log-stream-tests branch from 69f58ab to 1455482 Compare March 8, 2023 09:52
@sergiught sergiught force-pushed the DXCDT-386-log-stream-tests branch from 1455482 to a5d1b55 Compare March 8, 2023 09:59
Comment on lines +292 to +296
return nil, fmt.Errorf(
"there are currently no log streams of type: %q, use 'auth0 logs streams create %s' to create one",
desiredType,
desiredType,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always give command hints in other places, so this just makes things consistent.

Comment on lines 135 to 144
if oldLogStream.GetType() != string(logStreamTypeDatadog) {
return fmt.Errorf(
"the log stream with ID %q is of type %q instead of datadog, "+
"use 'auth0 logs streams update %s' to update it instead",
inputs.ID,
oldLogStream.GetType(),
oldLogStream.GetType(),
)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we prevent a panic down below when we type cast the sink property, this safeguards us against passing a real log stream ID but of different type. This is replicated in all the update commands.

@@ -97,7 +97,7 @@ func updateLogStreamsAmazonEventBridgeCmd(cli *cli) *cobra.Command {

cmd := &cobra.Command{
Use: "eventbridge",
Args: cobra.NoArgs,
Args: cobra.MaximumNArgs(1),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug where we weren't accepting any log stream id for the update command. We fix this here and in other update commands down below.

@sergiught sergiught marked this pull request as ready for review March 8, 2023 10:02
@sergiught sergiught requested a review from a team as a code owner March 8, 2023 10:02
Copy link
Contributor

@Widcket Widcket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work here improving the test coverage, just pointed out a couple of non-blocking nits.

@@ -132,6 +132,16 @@ func updateLogStreamsDatadogCmd(cli *cli) *cobra.Command {
return fmt.Errorf("failed to read log stream with ID %s: %w", inputs.ID, err)
}

if oldLogStream.GetType() != string(logStreamTypeDatadog) {
return fmt.Errorf(
"the log stream with ID %q is of type %q instead of datadog, "+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use logStreamTypeDatadog here?

@@ -124,6 +124,16 @@ func updateLogStreamsAmazonEventBridgeCmd(cli *cli) *cobra.Command {
return fmt.Errorf("failed to read log stream with ID %s: %w", inputs.ID, err)
}

if oldLogStream.GetType() != string(logStreamTypeAmazonEventBridge) {
return fmt.Errorf(
"the log stream with ID %q is of type %q instead of eventbridge, "+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use logStreamTypeAmazonEventBridge here?

@@ -139,6 +139,16 @@ func updateLogStreamsAzureEventGridCmd(cli *cli) *cobra.Command {
return fmt.Errorf("failed to read log stream with ID %s: %w", inputs.ID, err)
}

if oldLogStream.GetType() != string(logStreamTypeAzureEventGrid) {
return fmt.Errorf(
"the log stream with ID %q is of type %q instead of eventgrid, "+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use logStreamTypeAzureEventGrid here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the other log types

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 129d72f (#663)

Copy link
Contributor

@willvedd willvedd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 👍

@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@4c02d7b). Click here to learn what that means.
Patch coverage: 12.50% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #663   +/-   ##
=======================================
  Coverage        ?   51.26%           
=======================================
  Files           ?       92           
  Lines           ?    11576           
  Branches        ?        0           
=======================================
  Hits            ?     5934           
  Misses          ?     5213           
  Partials        ?      429           
Impacted Files Coverage Δ
internal/cli/log_streams.go 68.16% <0.00%> (ø)
internal/cli/log_streams_datadog.go 73.28% <0.00%> (ø)
internal/cli/log_streams_event_grid.go 43.47% <0.00%> (ø)
internal/cli/log_streams_event_bridge.go 73.39% <25.00%> (ø)
internal/cli/log_streams_http.go 67.44% <25.00%> (ø)
internal/cli/log_streams_splunk.go 71.16% <25.00%> (ø)
internal/cli/log_streams_sumo.go 74.33% <25.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sergiught sergiught merged commit db00760 into main Mar 8, 2023
@sergiught sergiught deleted the DXCDT-386-log-stream-tests branch March 8, 2023 13:51
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.

4 participants