(t *testing.T)
| 626 | } |
| 627 | |
| 628 | func TestQueryFileLocation(t *testing.T) { |
| 629 | testQueryTypes(t, memIndexTypes, func(qt *queryTest) { |
| 630 | id := qt.id |
| 631 | |
| 632 | // Upload a basic image |
| 633 | srcRoot, err := osutil.PkSourceRoot() |
| 634 | if err != nil { |
| 635 | panic(fmt.Sprintf("source root folder not found: %v", err)) |
| 636 | } |
| 637 | uploadFile := func(file string, modTime time.Time) blob.Ref { |
| 638 | fileName := filepath.Join(srcRoot, "pkg", "search", "testdata", file) |
| 639 | contents, err := os.ReadFile(fileName) |
| 640 | if err != nil { |
| 641 | panic(err) |
| 642 | } |
| 643 | br, _ := id.UploadFile(file, string(contents), modTime) |
| 644 | return br |
| 645 | } |
| 646 | fileRef := uploadFile("dude-gps.jpg", time.Time{}) |
| 647 | |
| 648 | p6 := id.NewPlannedPermanode("photo") |
| 649 | id.SetAttribute(p6, "camliContent", fileRef.String()) |
| 650 | |
| 651 | sq := &SearchQuery{ |
| 652 | Constraint: &Constraint{ |
| 653 | File: &FileConstraint{ |
| 654 | Location: &LocationConstraint{ |
| 655 | Any: true, |
| 656 | }, |
| 657 | }, |
| 658 | }, |
| 659 | } |
| 660 | |
| 661 | qt.wantRes(sq, fileRef) |
| 662 | if qt.res == nil { |
| 663 | t.Fatal("No results struct") |
| 664 | } |
| 665 | if qt.res.LocationArea == nil { |
| 666 | t.Fatal("No location area in results") |
| 667 | } |
| 668 | want := camtypes.LocationBounds{ |
| 669 | North: 42.45, |
| 670 | South: 42.45, |
| 671 | West: 18.76, |
| 672 | East: 18.76, |
| 673 | } |
| 674 | if *qt.res.LocationArea != want { |
| 675 | t.Fatalf("Wrong location area expansion: wanted %#v, got %#v", want, *qt.res.LocationArea) |
| 676 | } |
| 677 | |
| 678 | ExportSetExpandLocationHook(true) |
| 679 | qt.wantRes(sq) |
| 680 | if qt.res == nil { |
| 681 | t.Fatal("No results struct") |
| 682 | } |
| 683 | if qt.res.LocationArea != nil { |
| 684 | t.Fatalf("Location area should not have been expanded") |
| 685 | } |
nothing calls this directly
no test coverage detected