find permanode with a dir that contains a certain file or dir
(t *testing.T)
| 832 | |
| 833 | // find permanode with a dir that contains a certain file or dir |
| 834 | func TestQueryDirWithFileOrDirConstraint(t *testing.T) { |
| 835 | testQuery(t, func(qt *queryTest) { |
| 836 | id := qt.id |
| 837 | fileRef1, _ := id.UploadFile("some-stuff.txt", "hello", time.Unix(123, 0)) |
| 838 | qt.t.Logf("fileRef1 = %q", fileRef1) |
| 839 | childDirRef := id.UploadDir("childdir", []blob.Ref{}, time.Unix(457, 0)) |
| 840 | qt.t.Logf("childDirRef = %q", childDirRef) |
| 841 | dirRef := id.UploadDir("somedir", []blob.Ref{fileRef1, childDirRef}, time.Unix(789, 0)) |
| 842 | qt.t.Logf("dirRef = %q", dirRef) |
| 843 | p1 := id.NewPlannedPermanode("1") |
| 844 | id.SetAttribute(p1, "camliContent", dirRef.String()) |
| 845 | |
| 846 | fileRef3, _ := id.UploadFile("other-file", "hellooooo", time.Unix(101112, 0)) |
| 847 | qt.t.Logf("fileRef3 = %q", fileRef3) |
| 848 | p2 := id.NewPlannedPermanode("2") |
| 849 | id.SetAttribute(p2, "camliContent", fileRef3.String()) |
| 850 | |
| 851 | sq := &SearchQuery{ |
| 852 | Constraint: &Constraint{ |
| 853 | Permanode: &PermanodeConstraint{ |
| 854 | Attr: "camliContent", |
| 855 | ValueInSet: &Constraint{ |
| 856 | Dir: &DirConstraint{ |
| 857 | Contains: &Constraint{Logical: &LogicalConstraint{ |
| 858 | A: &Constraint{File: &FileConstraint{ |
| 859 | FileName: &StringConstraint{ |
| 860 | Equals: "foobar", |
| 861 | }, |
| 862 | }}, |
| 863 | B: &Constraint{Dir: &DirConstraint{ |
| 864 | FileName: &StringConstraint{ |
| 865 | Equals: "childdir", |
| 866 | }, |
| 867 | }}, |
| 868 | Op: "or", |
| 869 | }}, |
| 870 | }, |
| 871 | }, |
| 872 | }, |
| 873 | }, |
| 874 | } |
| 875 | qt.wantRes(sq, p1) |
| 876 | }) |
| 877 | } |
| 878 | |
| 879 | // find children of a directory, by name. |
| 880 | // in practice, one can also get the children with the proper describe rules, |
nothing calls this directly
no test coverage detected