github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/app/lib/search/result/match_test.go (about)

     1  //go:build test_all || !func_test
     2  
     3  // Package result - Content managed by Project Forge, see [projectforge.md] for details.
     4  package result_test
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/kyleu/dbaudit/app/lib/search/result"
    10  	"github.com/kyleu/dbaudit/app/util"
    11  )
    12  
    13  var splitTests = []struct {
    14  	q string
    15  	t string
    16  	r []string
    17  }{
    18  	{q: "foo", t: "there's a foo here", r: []string{"there's a ", "foo", " here"}},
    19  	{q: "foo", t: "foo is what this is", r: []string{"foo", " is what this is"}},
    20  	{q: "foo", t: "this is a foo", r: []string{"this is a ", "foo"}},
    21  	{q: "foo", t: "there's a foo here and a foo there", r: []string{"there's a ", "foo", " here and a ", "foo", " there"}},
    22  }
    23  
    24  func TestEncryptDecrypt(t *testing.T) {
    25  	t.Parallel()
    26  
    27  	for _, tt := range splitTests {
    28  		m := &result.Match{Key: "test", Value: tt.t}
    29  		r := m.ValueSplit(tt.q)
    30  		if len(tt.r) != len(r) {
    31  			t.Errorf("%s :: %s", tt.t, util.ToJSONCompact(r))
    32  		}
    33  	}
    34  }