For more development and stable use, we want to add tests
What
Added usecase_test.go which defines some usecases and expected results in table driven way
QA, Evidence
[x] run go test
$ go test -v ./... (git)-[usecase-testing]
? github.com/go-zen-chu/aictl/cmd/aictl/cmd [no test files]
? github.com/go-zen-chu/aictl/infra/git [no test files]
? github.com/go-zen-chu/aictl/infra/openai [no test files]
? github.com/go-zen-chu/aictl/internal/di [no test files]
? github.com/go-zen-chu/aictl/usecase/query [no test files]
=== RUN TestRootCmd
=== RUN TestRootCmd/If_no_args_given,_it_should_show_help_message
A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.
Usage:
aictl [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
query Run query to generative AI
Flags:
-h, --help help for aictl
-v, --verbose verbose output (log level debug)
Use "aictl [command] --help" for more information about a command.
=== RUN TestRootCmd/If_verbose_args_given,_it_should_show_debug_level_logs
time=2024-09-17T00:45:28.068+09:00 level=DEBUG msg="verbose debug log enabled"
A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.
Usage:
aictl [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
query Run query to generative AI
Flags:
-h, --help help for aictl
-v, --verbose verbose output (log level debug)
Use "aictl [command] --help" for more information about a command.
--- PASS: TestRootCmd (0.00s)
--- PASS: TestRootCmd/If_no_args_given,_it_should_show_help_message (0.00s)
--- PASS: TestRootCmd/If_verbose_args_given,_it_should_show_debug_level_logs (0.00s)
=== RUN TestQueryCmd
=== RUN TestQueryCmd/If_no_query_given,_it_should_get_an_error
Error: validation in query: query command requires only 1 argument `query text`
Usage:
aictl query [flags]
Flags:
-h, --help help for query
-l, --language string Which language you want to get response (default is English) (default "English")
-o, --output string Output format text or json (default is text) (default "text")
-i, --stdin Read query from stdin
-t, --text-files strings Text files added to query
Global Flags:
-v, --verbose verbose output (log level debug)
=== RUN TestQueryCmd/If_query_given,_it_should_get_response_from_OpenAI
Hello! How can I assist you today?
=== RUN TestQueryCmd/If_output_format_set_as_json,_it_should_get_response_from_OpenAI_with_json
{
"message": "Hello! How can I assist you today?"
}
=== RUN TestQueryCmd/If_output_format_is_empty,_it_should_get_validation_error
Error: validation in query: output format is required but got empty
Usage:
aictl query [flags]
Flags:
-h, --help help for query
-l, --language string Which language you want to get response (default is English) (default "English")
-o, --output string Output format text or json (default is text) (default "text")
-i, --stdin Read query from stdin
-t, --text-files strings Text files added to query
Global Flags:
-v, --verbose verbose output (log level debug)
=== RUN TestQueryCmd/If_output_format_set_as_yaml,_it_should_get_error_because_OpenAI_response_only_supports_text_or_json
Error: validation in query: output format must be text or json but got: yaml
Usage:
aictl query [flags]
Flags:
-h, --help help for query
-l, --language string Which language you want to get response (default is English) (default "English")
-o, --output string Output format text or json (default is text) (default "text")
-i, --stdin Read query from stdin
-t, --text-files strings Text files added to query
Global Flags:
-v, --verbose verbose output (log level debug)
=== RUN TestQueryCmd/If_response_language_given,_it_should_get_response_from_OpenAI_with_the_language
こんにちは!いかがですか?何かお手伝いできることがありますか?
--- PASS: TestQueryCmd (0.00s)
--- PASS: TestQueryCmd/If_no_query_given,_it_should_get_an_error (0.00s)
--- PASS: TestQueryCmd/If_query_given,_it_should_get_response_from_OpenAI (0.00s)
--- PASS: TestQueryCmd/If_output_format_set_as_json,_it_should_get_response_from_OpenAI_with_json (0.00s)
--- PASS: TestQueryCmd/If_output_format_is_empty,_it_should_get_validation_error (0.00s)
--- PASS: TestQueryCmd/If_output_format_set_as_yaml,_it_should_get_error_because_OpenAI_response_only_supports_text_or_json (0.00s)
--- PASS: TestQueryCmd/If_response_language_given,_it_should_get_response_from_OpenAI_with_the_language (0.00s)
PASS
ok github.com/go-zen-chu/aictl/cmd/aictl 0.376s
Why
What
QA, Evidence