diff --git a/app/publisher/publish_test.go b/app/publisher/publish_test.go index 963153d69..f46380458 100644 --- a/app/publisher/publish_test.go +++ b/app/publisher/publish_test.go @@ -26,12 +26,17 @@ import ( "time" "perkeep.org/internal/httputil" + "perkeep.org/internal/testhooks" camliClient "perkeep.org/pkg/client" "perkeep.org/pkg/index" "perkeep.org/pkg/index/indextest" "perkeep.org/pkg/search" ) +func init() { + testhooks.SetUseSHA1(true) +} + type publishURLTest struct { path string // input subject, subres string // expected @@ -121,24 +126,24 @@ type fakeClient struct { sh *search.Handler } -func (fc *fakeClient) Query(req *search.SearchQuery) (*search.SearchResult, error) { - return fc.sh.Query(req) +func (fc *fakeClient) Query(ctx context.Context, req *search.SearchQuery) (*search.SearchResult, error) { + return fc.sh.Query(ctx, req) } -func (fc *fakeClient) Search(req *search.SearchQuery) (*search.SearchResult, error) { - return fc.sh.Query(req) +func (fc *fakeClient) Search(ctx context.Context, req *search.SearchQuery) (*search.SearchResult, error) { + return fc.sh.Query(ctx, req) } func (fc *fakeClient) Describe(ctx context.Context, req *search.DescribeRequest) (*search.DescribeResponse, error) { return fc.sh.Describe(ctx, req) } -func (fc *fakeClient) GetJSON(url string, data interface{}) error { +func (fc *fakeClient) GetJSON(ctx context.Context, url string, data interface{}) error { // no need to implement return nil } -func (fc *fakeClient) Post(url string, bodyType string, body io.Reader) error { +func (fc *fakeClient) Post(ctx context.Context, url string, bodyType string, body io.Reader) error { // no need to implement return nil } @@ -148,13 +153,18 @@ func (fc *fakeClient) Post(url string, bodyType string, body io.Reader) error { func TestPublishURLs(t *testing.T) { rootName := "foo" idxd := setupContent(rootName) - sh := search.NewHandler(idxd.Index, idxd.SignerBlobRef) + ownerRef := indextest.PubKey + owner := index.NewOwner(indextest.KeyID, ownerRef.BlobRef()) + sh := search.NewHandler(idxd.Index, owner) corpus, err := idxd.Index.KeepInMemory() if err != nil { t.Fatalf("error slurping index to memory: %v", err) } sh.SetCorpus(corpus) - cl := camliClient.New("http://whatever.fake") + cl, err := camliClient.New(camliClient.OptionServer("http://whatever.fake")) + if err != nil { + t.Fatal(err) + } fcl := &fakeClient{cl, sh} ph := &publishHandler{ rootName: rootName, @@ -204,13 +214,18 @@ func TestPublishMembers(t *testing.T) { rootName := "foo" idxd := setupContent(rootName) - sh := search.NewHandler(idxd.Index, idxd.SignerBlobRef) + ownerRef := indextest.PubKey + owner := index.NewOwner(indextest.KeyID, ownerRef.BlobRef()) + sh := search.NewHandler(idxd.Index, owner) corpus, err := idxd.Index.KeepInMemory() if err != nil { t.Fatalf("error slurping index to memory: %v", err) } sh.SetCorpus(corpus) - cl := camliClient.New("http://whatever.fake") + cl, err := camliClient.New(camliClient.OptionServer("http://whatever.fake")) + if err != nil { + t.Fatal(err) + } fcl := &fakeClient{cl, sh} ph := &publishHandler{ rootName: rootName,