metabase / metabase/hawk

Support predicate checks within a collection with =?

Open
#23 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
60
Forks
1
PR merge metrics
No merged PRs in 30d

Description

```
(deftest foo-test
(is (=? even? 4)) ; passes
(is (=? {:foo even?} {:foo 42})) ; passes
(is (=? #{even?} #{2 4 6 8}))) ; fails: expected #{even?}, actual #{2 4 6 8}
```

If there's a collection that includes exactly one item which is a predicate function, I think `=?` should check that the actual value is of the given collection type and all of its elements pass the predicate.

[Motivating example in the wild from Metabase](https://github.com/metabase/metabase/blob/f50d839f6dcdda71dc865cc48fb20bda7193650a/test/metabase/api/table_test.clj#L146)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the implementation and tests for `=?`, then reproduce the shown `deftest` cases, especially the set containing `even?`. Confirm the desired behavior for a collection with one predicate: its type must match and every actual element must satisfy the predicate; the collection case should pass without changing the existing scalar and map cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.