refactor(cli): dedupe server/client option parsing and tighten CLI tests
- server_cli: handle --password-file/--early-input/--iconv via arg_has_value in one place, removing the unreachable duplicate separate-form arms while keeping both --opt VALUE and --opt=VALUE working - client_cli: factor the triplicated --delta-block/--block-size range check into set_delta_block_size(); drop the redundant use_metadata assignment after identity_parse_copy_as (the parser already forces it) - tests: cover both spellings of --iconv/--delta-block, make the archive short-form test actually call parse_args, add delta-block invalid cases
This commit is contained in:
+13
-6
@@ -164,19 +164,26 @@ static void test_server_cli_invalid() {
|
||||
}
|
||||
|
||||
static void test_server_cli_password_and_early_input() {
|
||||
const char* args[] = {"s", "--daemon", "--password-file=/etc/fast.pw", "--early-input",
|
||||
"/run/secrets"};
|
||||
const char* args[] = {"s",
|
||||
"--daemon",
|
||||
"--password-file=/etc/fast.pw",
|
||||
"--early-input",
|
||||
"/run/secrets",
|
||||
"--iconv=utf-8"};
|
||||
ServerCliOptions opts;
|
||||
EXPECT_EQ_INT(parse_ok(args, 5, &opts), 0);
|
||||
EXPECT_EQ_INT(parse_ok(args, 6, &opts), 0);
|
||||
EXPECT_EQ_STR(opts.password_file, "/etc/fast.pw");
|
||||
EXPECT_EQ_STR(opts.early_input_file, "/run/secrets");
|
||||
EXPECT_EQ_STR(opts.iconv_spec, "utf-8");
|
||||
|
||||
const char* args2[] = {"s", "--daemon", "--password-file", "/etc/fast.pw",
|
||||
"--early-input=/secrets"};
|
||||
const char* args2[] = {
|
||||
"s", "--daemon", "--password-file", "/etc/fast.pw", "--early-input=/secrets",
|
||||
"--iconv", "utf-8,iso-8859-1"};
|
||||
ServerCliOptions opts2;
|
||||
EXPECT_EQ_INT(parse_ok(args2, 5, &opts2), 0);
|
||||
EXPECT_EQ_INT(parse_ok(args2, 7, &opts2), 0);
|
||||
EXPECT_EQ_STR(opts2.password_file, "/etc/fast.pw");
|
||||
EXPECT_EQ_STR(opts2.early_input_file, "/secrets");
|
||||
EXPECT_EQ_STR(opts2.iconv_spec, "utf-8,iso-8859-1");
|
||||
server_cli_options_free(&opts);
|
||||
server_cli_options_free(&opts2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user