-
Notifications
You must be signed in to change notification settings - Fork 102
Fix- Print error messages in pre builder #829
Fix- Print error messages in pre builder #829
Conversation
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Codecov Report
@@ Coverage Diff @@
## master #829 +/- ##
==========================================
+ Coverage 84.34% 84.73% +0.39%
==========================================
Files 111 111
Lines 3857 3859 +2
==========================================
+ Hits 3253 3270 +17
+ Misses 432 419 -13
+ Partials 172 170 -2
Continue to review full report at Codecov.
|
internal/mocks/mocks.go
Outdated
type BuilderMock struct { | ||
mock.Mock | ||
} | ||
|
||
func (b *BuilderMock) Build(info formula.BuildInfo) error { | ||
args := b.Called(info) | ||
return args.Error(0) | ||
} | ||
func (b *BuilderMock) HasBuilt() bool { | ||
args := b.Called() | ||
return args.Bool(0) | ||
} |
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.
Can you move this to a dedicated file in mocks
with the package name? The mocks.go
file is getting large already
func (bm builderMock) HasBuilt() bool { | ||
return *bm.hasBuilt | ||
} | ||
|
||
type workspaceListHasherMock struct { |
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.
should we strive to eliminate this guy?
@@ -47,7 +47,8 @@ func NewPreRunBuilder( | |||
func (b PreRunBuilderManager) Build(relativePath string) { |
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 think you could return an error in this method, it will make your tests easier.
@@ -57,7 +58,8 @@ func (b PreRunBuilderManager) Build(relativePath string) { | |||
} | |||
|
|||
if err = b.buildOnWorkspace(*workspace, relativePath); err != nil { | |||
fmt.Println(prompt.Red(messageBuildError)) | |||
msg := fmt.Sprintf(messageBuildError, err.Error()) | |||
fmt.Println(prompt.Red(msg)) |
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.
Here it makes sense for you to return the error, so you prevent its repetition for the user.
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 will be change this method to return error.
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
…x/print-error-messages-in-pre-builder Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
…x/print-error-messages-in-pre-builder Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
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.
Nice, just a single comment
pkg/cmd/add_repo.go
Outdated
@@ -287,6 +288,7 @@ func (ar *addRepoCmd) resolveFlags(cmd *cobra.Command) (formula.Repo, error) { | |||
} | |||
} | |||
if !providerValid { | |||
sort.Strings(providers) |
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.
can you move the sort to inside the ar.repoProviders.List()
method? It should not be the responsibility of this command to know that. Also, this way we only need to edit a single point in code, other packages invoking this method could stumble upon the same problem
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.
Yes, I can change, you're right.
Can you add this PR to the pre run test of #788? |
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
2cc252b
/merge qa |
🔥 Merge Conflict |
…x/print-error-messages-in-pre-builder Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
Signed-off-by: Bruna Tavares <bruna.silva@zup.com.br>
🔥 Merge Conflict |
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.
LGTM 🚀
Description
This exposes the errors associated with the pre-build, improving the traceability and visibility of the error content.
Some extra improvements were the addition of new mocks and asserts in the tests.
How to verify it
Check the code or clone this pr, make the build and tests errors on build.
Changelog
Print error message in pre-builder