When running the tests with options set, such as `-update` for updating
"golden" files, this test would pick up test arguments because no arguments
were set to invoke the command;
go test . -update
Error: unknown shorthand flag: 'u' in -update
Usage:
events [OPTIONS] [flags]
Flags:
-f, --filter filter Filter output based on conditions provided
--format string Format output using a custom template:
'json': Print in JSON format
'TEMPLATE': Print output using the given Go template.
Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates
-h, --help help for events
--since string Show all events created since timestamp
--until string Stream events until this timestamp
--- FAIL: TestEventsFormat (0.00s)
--- FAIL: TestEventsFormat/default (0.00s)
events_test.go:75: assertion failed: error is not nil: unknown shorthand flag: 'u' in -update
--- FAIL: TestEventsFormat/json (0.00s)
events_test.go:75: assertion failed: error is not nil: unknown shorthand flag: 'u' in -update
--- FAIL: TestEventsFormat/json_template (0.00s)
events_test.go:75: assertion failed: error is not nil: unknown shorthand flag: 'u' in -update
--- FAIL: TestEventsFormat/json_action (0.00s)
events_test.go:75: assertion failed: error is not nil: unknown shorthand flag: 'u' in -update
This patch:
- changes the test to use command-arguments instead of manually setting the
flag options; this also adds test-coverage for parsing actual command arguments.
- discards stdout/stderr of the command to prevent noise in test output
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
go1.22 and up now produce a unique variable in loops, tehrefore no longer
requiring to capture the variable manually;
service/logs/parse_logs_test.go:50:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
tc := tc
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>