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

Test structify.MakeMapStructifier() #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Al2Klimov
Copy link
Member

No description provided.

@Al2Klimov Al2Klimov added the enhancement New feature or request label Jul 8, 2024
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Jul 8, 2024
@oxzi oxzi added the tests Adding tests to existing code label Jul 19, 2024
@Al2Klimov Al2Klimov removed the enhancement New feature or request label Jul 19, 2024
@Al2Klimov Al2Klimov requested a review from oxzi September 6, 2024 13:49
structify/structify_test.go Outdated Show resolved Hide resolved
func TestMakeMapStructifier(t *testing.T) {
subtests := []struct {
name string
tag string
Copy link
Member

Choose a reason for hiding this comment

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

tag is actually hard-coded, so it does not make sense to always specify it. If the empty test is the only case in which it must be the empty string, make a separate test.

Inline stringTest `test:",inline"`
}{Inline: stringTest{S: "foobar"}}},
{"missing_inline", "test", nil, map[string]any{"s": "foobar"}, false, &struct {
Inline stringTest
Copy link
Member

Choose a reason for hiding this comment

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

What about an actual test for embedded structs?

{"dash_tag", "test", nil, map[string]any{"s": "foobar"}, false, &struct {
S string `test:"-"`
}{}},
{"missing", "test", nil, nil, false, &stringTest{}},
Copy link
Member

Choose a reason for hiding this comment

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

Missing what?

error bool
output any
}{
{"empty", "", nil, nil, false, &struct{}{}},
Copy link
Member

Choose a reason for hiding this comment

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

This wall of code is barely readable, and testing is about what is actually being tested, so please make it readable instead of always trying to save lines at all costs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed CLA is signed by all contributors of a PR tests Adding tests to existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants