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

Fix visualize tests #405

Merged
merged 1 commit into from
Jan 26, 2024
Merged

Conversation

JacobOaks
Copy link
Contributor

PR #404 attempted to improve the tests in visualize_test.go by requiring length equality on the expected/actual ctors.

During CI, this actually uncovered a test failure:

--- FAIL: TestDotGraph (0.02s)
    --- FAIL: TestDotGraph/create_graph_with_one_constructor_and_as_interface_option (0.00s)
        visualize_test.go:453:
            	Error Trace:	visualize_test.go:453
            	            				visualize_test.go:117
            	Error:      	"[]" should have 1 item(s), but has 0
            	Test:       	TestDotGraph/create_graph_with_one_constructor_and_as_interface_option

This is because in this specific test case, the provide was never actually successful because of an error during provide (t5 did not implement io.Reader).

This commit:

  • Changes all of the provides that are expected to pass to RequireProvide which will fail if the provide fails.
  • Modifies t5 to implement io.Reader.
  • Change the test case to expect the provider to only provide the interface in the fx.As (fx.As does not also provide the actual type)
  • Add the len check from Improve visualize tests #404.

This supercedes #404.

PR uber-go#404 attempted to improve the tests in `visualize_test.go`
by requiring length equality on the expected/actual ctors.

During CI, this actually uncovered a test failure:
```
--- FAIL: TestDotGraph (0.02s)
    --- FAIL: TestDotGraph/create_graph_with_one_constructor_and_as_interface_option (0.00s)
        visualize_test.go:453:
            	Error Trace:	visualize_test.go:453
            	            				visualize_test.go:117
            	Error:      	"[]" should have 1 item(s), but has 0
            	Test:       	TestDotGraph/create_graph_with_one_constructor_and_as_interface_option
```

This is because, in this specific test case, the provide was never actually provided
because of an error during provide (`t5 did not implement io.Reader`).

This commit:
* Changes all of the provides that are expected to pass to `RequireProvide`
  which will fail if the provide fails.
* Modifies `t5` to implement `io.Reader`.
* Change the test case to expect the provider to only provide
  the interface in the `fx.As` (`fx.As` does not also provide the actual type)
* Add the len check from uber-go#404.
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (45369ac) 98.40% compared to head (dff4fbd) 98.40%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #405   +/-   ##
=======================================
  Coverage   98.40%   98.40%           
=======================================
  Files          22       22           
  Lines        1507     1507           
=======================================
  Hits         1483     1483           
  Misses         15       15           
  Partials        9        9           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JacobOaks JacobOaks merged commit 612c6c0 into uber-go:master Jan 26, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants