-
Notifications
You must be signed in to change notification settings - Fork 5
follow go style of table-driven tests more closesly #31
base: master
Are you sure you want to change the base?
follow go style of table-driven tests more closesly #31
Conversation
internal/lifecycle/readme_test.go
Outdated
if len(tc.codeBlock) == 0 { | ||
continue | ||
} | ||
t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) { |
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.
Instead of just giving a number here, your first arg to T.Run
should be a test case description. Add a name field to toCommandsTest
and fill that with a brief description, replacing the comments that you have added to each case. That way when there's a failure it's clear from the output which test case failed.
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.
Resolved, thank you. Does the updated version have the description format you were looking for?
Also uncommenting a test case that was originally commented out, addressed by #29. |
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.
Generally looks good, two small things. Run go test -v
to see the full output and confirm that it's what you're expecting.
internal/lifecycle/readme_test.go
Outdated
}, | ||
cmds: []*exec.Cmd{ | ||
exec.Command("echo", "hello", "world"), | ||
exec.Command("echo", "hello", "wosrld"), |
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.
typo? did you run this locally?
internal/lifecycle/readme_test.go
Outdated
var toCommandsTests = []toCommandsTest{ | ||
// single one-line command | ||
{ | ||
description: "single one-line command test", |
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.
You can leave "test" off the end of all of these.
In response to: #25 (comment)
Use
T.Run
for creating subtests for each test case.