DAOS-18304 ddb: Add Go unit tests for ddb command layer#18086
Draft
knard38 wants to merge 1 commit intockochhof/fix/master/daos-18304-patch-001from
Draft
DAOS-18304 ddb: Add Go unit tests for ddb command layer#18086knard38 wants to merge 1 commit intockochhof/fix/master/daos-18304-patch-001from
knard38 wants to merge 1 commit intockochhof/fix/master/daos-18304-patch-001from
Conversation
6 tasks
628036b to
c58c604
Compare
3c4faba to
24d96e6
Compare
|
Ticket title is 'Add unit test to ddb go code' |
24d96e6 to
f81f3be
Compare
8533ddb to
62c66ea
Compare
Add Go unit test coverage for the ddb command layer, made possible by
the DdbAPI interface introduced in the previous patch.
New files:
- test_helpers.go: DdbContextStub implementing DdbAPI for use in tests
without a live VOS environment; captureStdout, runCmdToStdout,
runMainFlow and isArgEqual test utilities.
- ddb_commands_test.go:
- TestHelpCmds: verifies help output for the ls and open commands.
- TestCmds: argument and option parsing for ls (path, --recursive,
--details) and open (--vos_path, --db_path, --write_mode).
- TestManPage: man page output to stdout and to file.
- main_test.go:
- TestParseOpts: general help, unknown commands with --help, default
option values, flag parsing (--debug, --write, --vos_path,
--db_path, --version) and error cases (conflicting --cmd /
--cmd_file, missing --vos_path when --db_path is set).
- TestRun: version output, unknown command detection, auto-open
behaviour with --vos_path and --db_path, command-line and
command-file execution modes.
- TestStrToLogLevels: all supported log level string conversions.
Features: recovery
Signed-off-by: Cedric Koch-Hofer <cedric.koch-hofer@hpe.com>
62c66ea to
6e01e12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Overview
Go unit test coverage for the ddb command layer, built on top of the
DdbAPIinterface introduced in the predecessor PR #17967.
Tests use a
DdbContextStubthat implementsDdbAPI, so they run without alive VOS environment and without CGo compilation.
New Files
test_helpers.goTest infrastructure shared across all test files:
DdbContextStub: a pure-Go implementation ofDdbAPIthat records callsand returns configurable errors, used as a drop-in replacement for
DdbContext.captureStdout: redirectsos.Stdoutto a pipe for the duration of afunction call and returns the captured output.
runCmdToStdout: callsparseOpts()with given args and captures stdout.runMainFlow: simulates the fullmain()execution flow (parse → versioncheck → run) without calling
os.Exit().isArgEqual: type-safe argument comparison helper for stub assertions.ddb_commands_test.goTests for the grumble command definitions:
TestHelpCmds: verifies--helpoutput for thelsandopencommands.TestCmds: argument and option parsing forls(path,--recursive,--details) andopen(--vos_path,--db_path,--write_mode).TestManPage: man page output to stdout and to file.main_test.goTests for the CLI entry-point logic:
TestParseOpts: general help, unknown commands with--help, defaultoption values, flag parsing (
--debug,--write,--vos_path,--db_path,--version) and error cases (conflicting--cmd/--cmd_file, missing--vos_pathwhen--db_pathis set).TestRun: version output, unknown command detection, auto-open behaviourwith
--vos_pathand--db_path, command-line and command-file execution modes.TestStrToLogLevels: all supported log level string conversions.Steps for the author:
After all prior steps are complete: