package matcher import ( "testing" ctxpkg "github.com/noahlann/nnet/pkg/context" routerpkg "github.com/noahlann/nnet/pkg/router" "github.com/stretchr/testify/assert" ) type dummyContext struct { ctxpkg.Context } func TestCompositeMatcher_AND(t *testing.T) { m1 := routerpkg.NewStringMatcher("hello") m2 := routerpkg.NewStringMatcher("hello*") and := routerpkg.NewAndMatcher(m1, m2) assert.True(t, and.Match(routerpkg.MatchInput{Raw: []byte("hello")}, &dummyContext{})) assert.False(t, and.Match(routerpkg.MatchInput{Raw: []byte("hi")}, &dummyContext{})) } func TestCompositeMatcher_OR(t *testing.T) { m1 := routerpkg.NewStringMatcher("hello") m2 := routerpkg.NewStringMatcher("ping") or := routerpkg.NewOrMatcher(m1, m2) assert.True(t, or.Match(routerpkg.MatchInput{Raw: []byte("hello")}, &dummyContext{})) assert.True(t, or.Match(routerpkg.MatchInput{Raw: []byte("ping")}, &dummyContext{})) assert.False(t, or.Match(routerpkg.MatchInput{Raw: []byte("other")}, &dummyContext{})) }