MCPcopy
hub / github.com/perkeep/perkeep / TestQueryDirConstraint

Function TestQueryDirConstraint

pkg/search/query_test.go:727–751  ·  view source on GitHub ↗

find a directory with a name

(t *testing.T)

Source from the content-addressed store, hash-verified

725
726// find a directory with a name
727func TestQueryDirConstraint(t *testing.T) {
728 testQuery(t, func(qt *queryTest) {
729 id := qt.id
730 dirRef := id.UploadDir("somedir", []blob.Ref{}, time.Unix(789, 0))
731 qt.t.Logf("dirRef = %q", dirRef)
732 p1 := id.NewPlannedPermanode("1")
733 id.SetAttribute(p1, "camliContent", dirRef.String())
734
735 fileRef3, _ := id.UploadFile("other-file", "hellooooo", time.Unix(101112, 0))
736 qt.t.Logf("fileRef3 = %q", fileRef3)
737 p2 := id.NewPlannedPermanode("2")
738 id.SetAttribute(p2, "camliContent", fileRef3.String())
739
740 sq := &SearchQuery{
741 Constraint: &Constraint{
742 Dir: &DirConstraint{
743 FileName: &StringConstraint{
744 Contains: "somedir",
745 },
746 },
747 },
748 }
749 qt.wantRes(sq, dirRef)
750 })
751}
752
753// find permanode with a dir that contains a certain file
754func TestQueryDirWithFileConstraint(t *testing.T) {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected