MCPcopy
hub / github.com/perkeep/perkeep / TestQueryDirWithFileConstraint

Function TestQueryDirWithFileConstraint

pkg/search/query_test.go:754–789  ·  view source on GitHub ↗

find permanode with a dir that contains a certain file

(t *testing.T)

Source from the content-addressed store, hash-verified

752
753// find permanode with a dir that contains a certain file
754func TestQueryDirWithFileConstraint(t *testing.T) {
755 testQuery(t, func(qt *queryTest) {
756 id := qt.id
757 fileRef1, _ := id.UploadFile("some-stuff.txt", "hello", time.Unix(123, 0))
758 qt.t.Logf("fileRef1 = %q", fileRef1)
759 fileRef2, _ := id.UploadFile("more-stuff.txt", "world", time.Unix(456, 0))
760 qt.t.Logf("fileRef2 = %q", fileRef2)
761 dirRef := id.UploadDir("somedir", []blob.Ref{fileRef1, fileRef2}, time.Unix(789, 0))
762 qt.t.Logf("dirRef = %q", dirRef)
763 p1 := id.NewPlannedPermanode("1")
764 id.SetAttribute(p1, "camliContent", dirRef.String())
765
766 fileRef3, _ := id.UploadFile("other-file", "hellooooo", time.Unix(101112, 0))
767 qt.t.Logf("fileRef3 = %q", fileRef3)
768 p2 := id.NewPlannedPermanode("2")
769 id.SetAttribute(p2, "camliContent", fileRef3.String())
770
771 sq := &SearchQuery{
772 Constraint: &Constraint{
773 Permanode: &PermanodeConstraint{
774 Attr: "camliContent",
775 ValueInSet: &Constraint{
776 Dir: &DirConstraint{
777 Contains: &Constraint{File: &FileConstraint{
778 FileName: &StringConstraint{
779 Contains: "some-stuff.txt",
780 },
781 }},
782 },
783 },
784 },
785 },
786 }
787 qt.wantRes(sq, p1)
788 })
789}
790
791// find a dir that doesn't contain any text files
792func TestQueryDirWithLogicalNotConstraint(t *testing.T) {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected