Skip to content

Commit

Permalink
test(complete): Simplify ArgValueCandidates test
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 21, 2024
1 parent 5f1eb96 commit 9bef077
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions clap_complete/tests/testsuite/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::fs;
use std::path::Path;

use clap::{builder::PossibleValue, Command};
use clap_complete::engine::{ArgValueCandidates, CompletionCandidate, ValueCandidates};
use clap_complete::engine::{ArgValueCandidates, CompletionCandidate};
use snapbox::assert_data_eq;

macro_rules! complete {
Expand Down Expand Up @@ -577,23 +577,18 @@ d_dir/

#[test]
fn suggest_custom_arg_value() {
#[derive(Debug)]
struct MyCustomCompleter {}

impl ValueCandidates for MyCustomCompleter {
fn candidates(&self) -> Vec<CompletionCandidate> {
vec![
CompletionCandidate::new("custom1"),
CompletionCandidate::new("custom2"),
CompletionCandidate::new("custom3"),
]
}
fn custom_completer() -> Vec<CompletionCandidate> {
vec![
CompletionCandidate::new("custom1"),
CompletionCandidate::new("custom2"),
CompletionCandidate::new("custom3"),
]
}

let mut cmd = Command::new("dynamic").arg(
clap::Arg::new("custom")
.long("custom")
.add::<ArgValueCandidates>(ArgValueCandidates::new(MyCustomCompleter {})),
.add(ArgValueCandidates::new(custom_completer)),
);

assert_data_eq!(
Expand Down

0 comments on commit 9bef077

Please sign in to comment.