| 1 |
//go:build notmuch |
| 2 |
// +build notmuch |
| 3 |
|
| 4 |
package notmuch |
| 5 |
|
| 6 |
import ( |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/stretchr/testify/assert" |
| 10 |
|
| 11 |
"git.sr.ht/~rjarry/aerc/worker/types" |
| 12 |
) |
| 13 |
|
| 14 |
func TestCriteria(t *testing.T) { |
| 15 |
criteria := types.SearchCriteria{ |
| 16 |
Match: &types.SearchCriteriaPart{ |
| 17 |
From: []string{"from1", "from2"}, |
| 18 |
To: []string{"to"}, |
| 19 |
}, |
| 20 |
} |
| 21 |
query := translate(&criteria) |
| 22 |
assert.Equal(t, "((from:from1) or (from:from2)) and ((to:to))", query) |
| 23 |
} |
| 24 |
|
| 25 |
func TestExclude(t *testing.T) { |
| 26 |
criteria := types.SearchCriteria{ |
| 27 |
Match: &types.SearchCriteriaPart{ |
| 28 |
From: []string{"from"}, |
| 29 |
}, |
| 30 |
Exclude: &types.SearchCriteriaPart{ |
| 31 |
Invert: true, |
| 32 |
To: []string{"to1", "to2"}, |
| 33 |
}, |
| 34 |
} |
| 35 |
query := translate(&criteria) |
| 36 |
assert.Equal(t, "((from:from)) and (not ((to:to1) or (to:to2)))", query) |
| 37 |
} |