MCPcopy
hub / github.com/perkeep/perkeep / TestQueryFileConstraint

Function TestQueryFileConstraint

pkg/search/query_test.go:692–724  ·  view source on GitHub ↗

find permanodes matching a certain file query

(t *testing.T)

Source from the content-addressed store, hash-verified

690
691// find permanodes matching a certain file query
692func TestQueryFileConstraint(t *testing.T) {
693 testQuery(t, func(qt *queryTest) {
694 id := qt.id
695 fileRef, _ := id.UploadFile("some-stuff.txt", "hello", time.Unix(123, 0))
696 qt.t.Logf("fileRef = %q", fileRef)
697 p1 := id.NewPlannedPermanode("1")
698 id.SetAttribute(p1, "camliContent", fileRef.String())
699
700 fileRef2, _ := id.UploadFile("other-file", "hellooooo", time.Unix(456, 0))
701 qt.t.Logf("fileRef2 = %q", fileRef2)
702 p2 := id.NewPlannedPermanode("2")
703 id.SetAttribute(p2, "camliContent", fileRef2.String())
704
705 sq := &SearchQuery{
706 Constraint: &Constraint{
707 Permanode: &PermanodeConstraint{
708 Attr: "camliContent",
709 ValueInSet: &Constraint{
710 File: &FileConstraint{
711 FileName: &StringConstraint{
712 Contains: "-stuff",
713 },
714 FileSize: &IntConstraint{
715 Max: 5,
716 },
717 },
718 },
719 },
720 },
721 }
722 qt.wantRes(sq, p1)
723 })
724}
725
726// find a directory with a name
727func TestQueryDirConstraint(t *testing.T) {

Callers

nothing calls this directly

Calls 7

testQueryFunction · 0.85
LogfMethod · 0.80
NewPlannedPermanodeMethod · 0.80
SetAttributeMethod · 0.80
wantResMethod · 0.80
UploadFileMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected