mirror of
https://github.com/sbrow/envr.git
synced 2026-06-27 18:48:33 -04:00
test: Rewrote expect checks to use expect_value where appropriate.
This commit is contained in:
@@ -123,7 +123,7 @@ test_command_help_unknown :: proc(t: ^testing.T) {
|
||||
|
||||
text := strings.to_string(b)
|
||||
testing.expect_value(t, len(text), 0)
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_command_help_version :: proc(t: ^testing.T) {
|
||||
@@ -236,9 +236,9 @@ test_parse_args_positional :: proc(t: ^testing.T) {
|
||||
testing.expect(t, ok, "should succeed")
|
||||
|
||||
testing.expect_value(t, cmd.name, "backup")
|
||||
testing.expect(t, len(cmd.args) == 1)
|
||||
testing.expect(t, cmd.args[0] == "/project/.env")
|
||||
}
|
||||
testing.expect_value(t, len(cmd.args), 1)
|
||||
testing.expect_value(t, cmd.args[0], "/project/.env")
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_long_flag_with_value :: proc(t: ^testing.T) {
|
||||
@@ -248,7 +248,7 @@ test_parse_args_long_flag_with_value :: proc(t: ^testing.T) {
|
||||
defer delete_command(&cmd)
|
||||
|
||||
testing.expect_value(t, cmd.flags["config"], "x.json")
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_short_flag_with_value :: proc(t: ^testing.T) {
|
||||
@@ -258,7 +258,7 @@ test_parse_args_short_flag_with_value :: proc(t: ^testing.T) {
|
||||
defer delete_command(&cmd)
|
||||
|
||||
testing.expect_value(t, cmd.flags["c"], "x.json")
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_long_bool_flag :: proc(t: ^testing.T) {
|
||||
@@ -268,7 +268,7 @@ test_parse_args_long_bool_flag :: proc(t: ^testing.T) {
|
||||
defer delete_command(&cmd)
|
||||
|
||||
testing.expect_value(t, cmd.bool_set["force"], true)
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_short_bool_flag :: proc(t: ^testing.T) {
|
||||
@@ -278,7 +278,7 @@ test_parse_args_short_bool_flag :: proc(t: ^testing.T) {
|
||||
defer delete_command(&cmd)
|
||||
|
||||
testing.expect_value(t, cmd.bool_set["l"], true)
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_multiple_positionals :: proc(t: ^testing.T) {
|
||||
@@ -288,9 +288,9 @@ test_parse_args_multiple_positionals :: proc(t: ^testing.T) {
|
||||
defer delete_command(&cmd)
|
||||
|
||||
testing.expect_value(t, len(cmd.args), 2)
|
||||
testing.expect(t, cmd.args[0] == "a")
|
||||
testing.expect(t, cmd.args[1] == "b")
|
||||
}
|
||||
testing.expect_value(t, cmd.args[0], "a")
|
||||
testing.expect_value(t, cmd.args[1], "b")
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_mixed_flags_and_positionals :: proc(t: ^testing.T) {
|
||||
@@ -300,9 +300,9 @@ test_parse_args_mixed_flags_and_positionals :: proc(t: ^testing.T) {
|
||||
defer delete_command(&cmd)
|
||||
|
||||
testing.expect_value(t, cmd.bool_set["force"], true)
|
||||
testing.expect(t, len(cmd.args) == 1)
|
||||
testing.expect(t, cmd.args[0] == "/project/.env")
|
||||
}
|
||||
testing.expect_value(t, len(cmd.args), 1)
|
||||
testing.expect_value(t, cmd.args[0], "/project/.env")
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_no_args :: proc(t: ^testing.T) {
|
||||
@@ -318,10 +318,10 @@ test_parse_args_flag_then_positional_then_flag :: proc(t: ^testing.T) {
|
||||
testing.expect(t, ok, "should succeed")
|
||||
|
||||
testing.expect_value(t, cmd.bool_set["force"], true)
|
||||
testing.expect(t, cmd.bool_set["verbose"] == true)
|
||||
testing.expect(t, len(cmd.args) == 1)
|
||||
testing.expect(t, cmd.args[0] == "a.env")
|
||||
}
|
||||
testing.expect_value(t, cmd.bool_set["verbose"], true)
|
||||
testing.expect_value(t, len(cmd.args), 1)
|
||||
testing.expect_value(t, cmd.args[0], "a.env")
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_config_file_long_flag :: proc(t: ^testing.T) {
|
||||
@@ -333,11 +333,7 @@ test_parse_args_config_file_long_flag :: proc(t: ^testing.T) {
|
||||
defer delete_command(&cmd)
|
||||
|
||||
testing.expect_value(t, cmd.config_path, "/custom/config.json")
|
||||
t,
|
||||
cmd.config_path == "/custom/config.json",
|
||||
"config_path should be set from --config-file",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_config_file_short_flag :: proc(t: ^testing.T) {
|
||||
@@ -347,11 +343,7 @@ test_parse_args_config_file_short_flag :: proc(t: ^testing.T) {
|
||||
defer delete_command(&cmd)
|
||||
|
||||
testing.expect_value(t, cmd.config_path, "/custom/config.json")
|
||||
t,
|
||||
cmd.config_path == "/custom/config.json",
|
||||
"config_path should be set from -c",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_parse_args_config_file_defaults :: proc(t: ^testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user