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

toolsconfig:chore: create tests and rename public objects #764

Merged
merged 1 commit into from
Nov 12, 2021

Conversation

matheusalcantarazup
Copy link
Contributor

@matheusalcantarazup matheusalcantarazup commented Nov 11, 2021

Previously the toolsconfig package does not have any unit tests and the
public functions and types was a bit confused, since two types was
exported to represents the same "thing".

This commit implements the tests to cover scenarios of toolsconfig
parsing.

This commit also rename ToolsConfigStruct to toolsConfig and also made
private, since this struct is only used as schema to parse the values
and only the Map type is used by other packages. The Map and Config
struct was also renamed to don't be repetitive on names.

The function ParseInterfaceToMapToolsConfig was also renamed to
MustParseToolsConfig to follow the Go standards of functions that can
cause errors that will be not returned. The signature was also changed
to avoid bugs when accepting an empty interface{}, since the viper will
always return a map[string]interface{} when we get the tools config from
config file, this function does not need to accept an empty interface.

A new function Default was also created to return the default values
from tools config.

Updates #718

Signed-off-by: Matheus Alcantara [email protected]

- What I did

- How to verify it

- Description for the changelog

Previously the toolsconfig package does not have any unit tests and the
public functions and types was a bit confused, since two types was
exported to represents the same "thing".

This commit implements the tests to cover scenarios of toolsconfig
parsing.

This commit also rename ToolsConfigStruct to toolsConfig and also made
private, since this struct is only used as schema to parse the values
and only the Map type is used by other packages. The Map and Config
struct was also renamed to don't be repetitive on names.

The function ParseInterfaceToMapToolsConfig was also renamed to
MustParseToolsConfig to follow the Go standards of functions that can
cause errors that will be not returned. The signature was also changed
to avoid bugs when accepting an empty interface{}, since the viper will
always return a map[string]interface{} when we get the tools config from
config file, this function does not need to accept an empty interface.

A new function Default was also created to return the default values
from tools config.

Updates #718

Signed-off-by: Matheus Alcantara <[email protected]>
@matheusalcantarazup matheusalcantarazup merged commit 637fa62 into main Nov 12, 2021
@matheusalcantarazup matheusalcantarazup deleted the tests-tools-config branch November 12, 2021 11:55
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