# editor: Use fuzzy crate in code completions tests instead of hard coded values \(\#32565\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/65a1d09d245123d5665f815286eeb740e382ecdd)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 65a1d09d245123d5665f815286eeb740e382ecdd

Requested commit: 65a1d09d245123d5665f815286eeb740e382ecdd

Commit: 65a1d09d245123d5665f815286eeb740e382ecdd

Tree: 235197a197dd7b4e9c5e31270620329fd0c093be

Author: Smit Barmase

Committer: GitHub

## Message

````
editor: Use fuzzy crate in code completions tests instead of hard coded values (#32565)

This PR makes it a lot cleaner to write code completion tests. It
doesn't contain any logical changes, just refactoring.

Before, we used to depend on hard-coded values of fuzzy score and its
positions for tests. Now we don't need them, as fuzzy crate will handle
that for us. This is possible because fuzzy match score isn't dependent
on relative candidates or the number of candidates; rather, it's just a
one-to-one mapping for each candidate and its score.

This also makes it test robust for future purposes if there are changes
in fuzzy score logic.

Before:
```rs
  SortableMatch {
            string_match: StringMatch {  // -> whole struct provided by fuzzy crate
                candidate_id: 1115,
                score: 1.0,
                positions: vec![],
                string: "Item".to_string(),
            },
            is_snippet: false,  // -> changed to snippet kind
            sort_text: Some("16"),
            sort_kind: 3, // -> changed to function, constant, variable kind
            sort_label: "Item",
        },
```

After:
```rs
  CompletionBuilder::function("Item", "16")
```

Release Notes:

- N/A
````

## Parents

- [7f150f7e0fe0da32df4c974b13e717f16e838e1f](https://git.cafe/gitcafe/zed/commit/7f150f7e0fe0da32df4c974b13e717f16e838e1f?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/65a1d09d245123d5665f815286eeb740e382ecdd?format=markdown)
