From bb1ccab7c58374b174ee629a52b1ee18fc0721d1 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Mon, 9 Oct 2023 09:59:05 +0545 Subject: [PATCH] Refactor to share test --- featurecontext/featurecontext.go | 2 -- features/concurrent-user-sharing.feature | 11 +++++------ scenario/featurecontext.go | 6 +++--- steps/{sampletest => share}/context.go | 12 ++++++------ steps/{sampletest => share}/steps.go | 6 +++--- 5 files changed, 17 insertions(+), 20 deletions(-) rename steps/{sampletest => share}/context.go (53%) rename steps/{sampletest => share}/steps.go (95%) diff --git a/featurecontext/featurecontext.go b/featurecontext/featurecontext.go index 67bd1f0..7cdfb46 100644 --- a/featurecontext/featurecontext.go +++ b/featurecontext/featurecontext.go @@ -5,7 +5,6 @@ import ( gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" - shareClient "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1" providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" ) @@ -24,7 +23,6 @@ type ResourceAlias struct { type FeatureContext struct { Client gateway.GatewayAPIClient HTTPClient http.Client - ShareClient shareClient.CollaborationAPIClient // remember the last response to check the outcome Response interface{} diff --git a/features/concurrent-user-sharing.feature b/features/concurrent-user-sharing.feature index 200c186..3dd5d46 100644 --- a/features/concurrent-user-sharing.feature +++ b/features/concurrent-user-sharing.feature @@ -1,14 +1,13 @@ Feature: concurrent user sharing - As a users - Users want to share their resource concurrently + As a user + I want to share their resource concurrently to different multiple users + - @concurrent Scenario: users make concurrent sharing to each other Given user "admin" has logged in with password "admin" And user "admin" has created a personal space with the alias "Admin Home" - And user "admin" has uploaded a file "testfile1.txt" with content "concurrent sharing" in the home directory with the alias "testfile1" - And user "admin" has uploaded a file "testfile2.txt" with content "concurrent sharing" in the home directory with the alias "testfile2" - When user "admin" shares a file "testfile1.txt" with the following users concurrently + And user "admin" has uploaded a file "testfile.txt" with content "concurrent sharing" in the home directory with the alias "testfile1" + When user "admin" shares a file "testfile.txt" with the following users concurrently | users | | marie | | moss | diff --git a/scenario/featurecontext.go b/scenario/featurecontext.go index cf66fb1..3357ed6 100644 --- a/scenario/featurecontext.go +++ b/scenario/featurecontext.go @@ -6,8 +6,8 @@ import ( "github.com/owncloud/cs3api-validator/steps/login" "github.com/owncloud/cs3api-validator/steps/publicshare" "github.com/owncloud/cs3api-validator/steps/resources" + "github.com/owncloud/cs3api-validator/steps/share" "github.com/owncloud/cs3api-validator/steps/spaces" - "github.com/owncloud/cs3api-validator/steps/sampletest" ) // featureContext embeds all available feature contexts @@ -18,7 +18,7 @@ type featureContext struct { *publicshare.PublicShareFeatureContext *resources.ResourcesFeatureContext *spaces.SpacesFeatureContext - *sampletest.SampleTestFeatureContext + *share.ShareTestFeatureContext } // newFeatureContext returns a new feature context for the scenario initialization @@ -34,7 +34,7 @@ func newFeatureContext(sc *godog.ScenarioContext) *featureContext { PublicShareFeatureContext: publicshare.NewPublicShareFeatureContext(fc, sc), ResourcesFeatureContext: resources.NewResourcesFeatureContext(fc, sc), SpacesFeatureContext: spaces.NewSpacesFeatureContext(fc, sc), - SampleTestFeatureContext: sampletest.NewSampleTestFeatureContext(fc, sc), + ShareTestFeatureContext: share.NewShareTestFeatureContext(fc, sc), } return uc } diff --git a/steps/sampletest/context.go b/steps/share/context.go similarity index 53% rename from steps/sampletest/context.go rename to steps/share/context.go index 0db395a..2861b67 100644 --- a/steps/sampletest/context.go +++ b/steps/share/context.go @@ -1,22 +1,22 @@ -package sampletest +package share import ( "github.com/cucumber/godog" "github.com/owncloud/cs3api-validator/featurecontext" ) -// SampleTestFeatureContext holds values which are used across test steps -type SampleTestFeatureContext struct { +// ShareTestFeatureContext holds values which are used across test steps +type ShareTestFeatureContext struct { *featurecontext.FeatureContext } -func NewSampleTestFeatureContext(fc *featurecontext.FeatureContext, sc *godog.ScenarioContext) *SampleTestFeatureContext { - nsc := &SampleTestFeatureContext{FeatureContext: fc} +func NewShareTestFeatureContext(fc *featurecontext.FeatureContext, sc *godog.ScenarioContext) *ShareTestFeatureContext { + nsc := &ShareTestFeatureContext{FeatureContext: fc} nsc.Register(sc) return nsc } -func (f *SampleTestFeatureContext) Register(ctx *godog.ScenarioContext) { +func (f *ShareTestFeatureContext) Register(ctx *godog.ScenarioContext) { // steps ctx.Step(`^user "([^"]*)" shares a file "([^"]*)" with the following users concurrently$`, f.UserSharesAFileWithTheFollowingUsers) ctx.Step(`^the concurrent user sharing should have been successfull$`, f.TheConcurrentUserSharingShouldHaveBeenSuccessfull) diff --git a/steps/sampletest/steps.go b/steps/share/steps.go similarity index 95% rename from steps/sampletest/steps.go rename to steps/share/steps.go index 01d2d02..0904916 100644 --- a/steps/sampletest/steps.go +++ b/steps/share/steps.go @@ -1,4 +1,4 @@ -package sampletest +package share import ( "fmt" @@ -22,7 +22,7 @@ type CreateShareResult struct { var concurentResults []*CreateShareResult -func (f *SampleTestFeatureContext) UserSharesAFileWithTheFollowingUsers(shareer string, resourceName string, sharees *godog.Table) error { +func (f *ShareTestFeatureContext) UserSharesAFileWithTheFollowingUsers(shareer string, resourceName string, sharees *godog.Table) error { ctx, err := f.GetAuthContext(shareer) if err != nil { return err @@ -152,7 +152,7 @@ func (f *SampleTestFeatureContext) UserSharesAFileWithTheFollowingUsers(shareer return nil } -func (f *SampleTestFeatureContext) TheConcurrentUserSharingShouldHaveBeenSuccessfull() error { +func (f *ShareTestFeatureContext) TheConcurrentUserSharingShouldHaveBeenSuccessfull() error { //collect the result summary if there is any error while concurrent sharing var isThereConcurrentError bool var errorSummary string