mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-09-06 21:21:36 +02:00
add test for Filter.Search
This commit is contained in:
committed by
fiatjaf_
parent
75a07daf7b
commit
2d7dae3f69
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestFilterUnmarshal(t *testing.T) {
|
func TestFilterUnmarshal(t *testing.T) {
|
||||||
raw := `{"ids": ["abc"],"#e":["zzz"],"#something":["nothing","bab"],"since":1644254609}`
|
raw := `{"ids": ["abc"],"#e":["zzz"],"#something":["nothing","bab"],"since":1644254609,"search":"test"}`
|
||||||
var f Filter
|
var f Filter
|
||||||
err := json.Unmarshal([]byte(raw), &f)
|
err := json.Unmarshal([]byte(raw), &f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -18,7 +18,8 @@ func TestFilterUnmarshal(t *testing.T) {
|
|||||||
|
|
||||||
if f.Since == nil || f.Since.UTC().Format("2006-01-02") != "2022-02-07" ||
|
if f.Since == nil || f.Since.UTC().Format("2006-01-02") != "2022-02-07" ||
|
||||||
f.Until != nil ||
|
f.Until != nil ||
|
||||||
f.Tags == nil || len(f.Tags) != 2 || !slices.Contains(f.Tags["something"], "bab") {
|
f.Tags == nil || len(f.Tags) != 2 || !slices.Contains(f.Tags["something"], "bab") ||
|
||||||
|
f.Search != "test" {
|
||||||
t.Error("failed to parse filter correctly")
|
t.Error("failed to parse filter correctly")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user