aboutsummaryrefslogtreecommitdiff
path: root/weed/server/filer_grpc_server_traverse_meta_test.go
blob: 72f8a916ea6c6957e2dc379f5b1476d2b6cdb0c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package weed_server

import (
	"github.com/stretchr/testify/assert"
	"github.com/viant/ptrie"
	"testing"
)

func TestPtrie(t *testing.T) {
	b := []byte("/topics/abc/dev")
	excludedTrie := ptrie.New[bool]()
	excludedTrie.Put([]byte("/topics/abc/d"), true)
	excludedTrie.Put([]byte("/topics/abc"), true)

	assert.True(t, excludedTrie.MatchPrefix(b, func(key []byte, value bool) bool {
		println("matched1", string(key))
		return true
	}))

	assert.True(t, excludedTrie.MatchAll(b, func(key []byte, value bool) bool {
		println("matched2", string(key))
		return true
	}))

	assert.False(t, excludedTrie.MatchAll([]byte("/topics/ab"), func(key []byte, value bool) bool {
		println("matched3", string(key))
		return true
	}))

	assert.False(t, excludedTrie.Has(b))
}