From 7bbc387af1728e82197e30492e488ade097e11eb Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Wed, 7 Oct 2020 16:22:21 +0200 Subject: [PATCH] start metadata storage in tests --- .../pkg/indexer/index/cs3/non_unique_test.go | 10 ++++-- accounts/pkg/indexer/index/cs3/unique_test.go | 34 ++++++++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/accounts/pkg/indexer/index/cs3/non_unique_test.go b/accounts/pkg/indexer/index/cs3/non_unique_test.go index a4415db83..13aba43ff 100644 --- a/accounts/pkg/indexer/index/cs3/non_unique_test.go +++ b/accounts/pkg/indexer/index/cs3/non_unique_test.go @@ -1,16 +1,20 @@ package cs3 import ( + "os" + "path" + "testing" + "github.com/owncloud/ocis/accounts/pkg/config" "github.com/owncloud/ocis/accounts/pkg/indexer/option" . "github.com/owncloud/ocis/accounts/pkg/indexer/test" "github.com/stretchr/testify/assert" - "os" - "path" - "testing" ) func TestCS3NonUniqueIndex_FakeSymlink(t *testing.T) { + go setupMetadataStorage() + defer cancelFunc() + dataDir := WriteIndexTestDataCS3(t, TestData, "Id") cfg := config.Config{ Repo: config.Repo{ diff --git a/accounts/pkg/indexer/index/cs3/unique_test.go b/accounts/pkg/indexer/index/cs3/unique_test.go index 8a9de7b2f..c0ef69d48 100644 --- a/accounts/pkg/indexer/index/cs3/unique_test.go +++ b/accounts/pkg/indexer/index/cs3/unique_test.go @@ -1,16 +1,39 @@ package cs3 import ( - "github.com/owncloud/ocis/accounts/pkg/config" - "github.com/owncloud/ocis/accounts/pkg/indexer/option" - . "github.com/owncloud/ocis/accounts/pkg/indexer/test" - "github.com/stretchr/testify/assert" + "context" + "flag" "os" "path" "testing" + + "github.com/micro/cli/v2" + "github.com/owncloud/ocis/accounts/pkg/config" + "github.com/owncloud/ocis/accounts/pkg/indexer/option" + . "github.com/owncloud/ocis/accounts/pkg/indexer/test" + "github.com/owncloud/ocis/storage/pkg/command" + mcfg "github.com/owncloud/ocis/storage/pkg/config" + "github.com/stretchr/testify/assert" ) +var ( + ctx, cancelFunc = context.WithCancel(context.Background()) +) + +func setupMetadataStorage() { + cfg := mcfg.New() + app := cli.App{ + Name: "storage-metadata-for-tests", + Commands: []*cli.Command{command.StorageMetadata(cfg)}, + } + + _ = app.Command("storage-metadata").Run(cli.NewContext(&app, &flag.FlagSet{}, &cli.Context{Context: ctx})) +} + func TestCS3UniqueIndex_FakeSymlink(t *testing.T) { + go setupMetadataStorage() + defer cancelFunc() + dataDir := WriteIndexTestDataCS3(t, TestData, "Id") cfg := config.Config{ Repo: config.Repo{ @@ -60,6 +83,9 @@ func TestCS3UniqueIndex_FakeSymlink(t *testing.T) { } func TestCS3UniqueIndexSearch(t *testing.T) { + go setupMetadataStorage() + defer cancelFunc() + dataDir := WriteIndexTestDataCS3(t, TestData, "Id") cfg := config.Config{ Repo: config.Repo{