mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cli: fix failing test on macos/windows
This commit is contained in:
parent
e5a508c0d7
commit
ca8344460a
@ -51,13 +51,16 @@ fn test_if_command_has_default_version_subcommand_if_version_is_set() {
|
||||
assert has_command(cmd, 'version')
|
||||
}
|
||||
|
||||
|
||||
fn flag_should_be_set(cmd cli.Command) ? {
|
||||
flag := cmd.flags.get_string('flag')?
|
||||
assert flag == 'value'
|
||||
}
|
||||
|
||||
fn test_if_flag_gets_set() {
|
||||
mut cmd := cli.Command{
|
||||
name: 'command'
|
||||
execute: fn (cmd cli.Command) ? {
|
||||
flag := cmd.flags.get_string('flag')?
|
||||
assert flag == 'value'
|
||||
}
|
||||
execute: flag_should_be_set
|
||||
}
|
||||
cmd.add_flag(cli.Flag{
|
||||
flag: .string
|
||||
@ -69,10 +72,7 @@ fn test_if_flag_gets_set() {
|
||||
fn test_if_flag_gets_set_with_abbrev() {
|
||||
mut cmd := cli.Command{
|
||||
name: 'command'
|
||||
execute: fn (cmd cli.Command) ? {
|
||||
flag := cmd.flags.get_string('flag')?
|
||||
assert flag == 'value'
|
||||
}
|
||||
execute: flag_should_be_set
|
||||
}
|
||||
cmd.add_flag(cli.Flag{
|
||||
flag: .string
|
||||
@ -83,14 +83,18 @@ fn test_if_flag_gets_set_with_abbrev() {
|
||||
cmd.parse(['command', '--flag', 'value'])
|
||||
}
|
||||
|
||||
|
||||
fn flag_should_have_value_of_42(cmd cli.Command) ? {
|
||||
flag := cmd.flags.get_string('flag')?
|
||||
assert flag == 'value'
|
||||
value := cmd.flags.get_int('value')?
|
||||
assert value == 42
|
||||
}
|
||||
|
||||
fn test_if_multiple_flags_get_set() {
|
||||
mut cmd := cli.Command{
|
||||
name: 'command'
|
||||
execute: fn (cmd cli.Command) ? {
|
||||
flag := cmd.flags.get_string('flag')?
|
||||
value := cmd.flags.get_int('value')?
|
||||
assert flag == 'value' && value == 42
|
||||
}
|
||||
execute: flag_should_have_value_of_42
|
||||
}
|
||||
cmd.add_flag(cli.Flag{
|
||||
flag: .string
|
||||
@ -103,6 +107,14 @@ fn test_if_multiple_flags_get_set() {
|
||||
cmd.parse(['command', '-flag', 'value', '-value', '42'])
|
||||
}
|
||||
|
||||
|
||||
fn flag_is_set_in_subcommand(cmd cli.Command) ? {
|
||||
flag := cmd.flags.get_string('flag') or {
|
||||
panic(err)
|
||||
}
|
||||
assert flag == 'value'
|
||||
}
|
||||
|
||||
fn test_if_flag_gets_set_in_subcommand() {
|
||||
mut cmd := cli.Command{
|
||||
name: 'command'
|
||||
@ -110,12 +122,7 @@ fn test_if_flag_gets_set_in_subcommand() {
|
||||
}
|
||||
mut subcmd := cli.Command{
|
||||
name: 'subcommand'
|
||||
execute: fn (cmd cli.Command) ? {
|
||||
flag := cmd.flags.get_string('flag') or {
|
||||
panic(err)
|
||||
}
|
||||
assert flag == 'value'
|
||||
}
|
||||
execute: flag_is_set_in_subcommand
|
||||
}
|
||||
subcmd.add_flag(cli.Flag{
|
||||
flag: .string
|
||||
@ -137,12 +144,7 @@ fn test_if_global_flag_gets_set_in_subcommand() {
|
||||
})
|
||||
subcmd := cli.Command{
|
||||
name: 'subcommand'
|
||||
execute: fn (cmd cli.Command) {
|
||||
flag := cmd.flags.get_string('flag') or {
|
||||
panic(err)
|
||||
}
|
||||
assert flag == 'value'
|
||||
}
|
||||
execute: flag_is_set_in_subcommand
|
||||
}
|
||||
cmd.add_command(subcmd)
|
||||
cmd.parse(['command', '-flag', 'value', 'subcommand'])
|
||||
|
Loading…
Reference in New Issue
Block a user