Skip to content

Commit

Permalink
Refactor to share test
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarGi committed Oct 9, 2023
1 parent feb5673 commit 9ad5032
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
2 changes: 0 additions & 2 deletions featurecontext/featurecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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{}
Expand Down
4 changes: 2 additions & 2 deletions features/concurrent-user-sharing.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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
Expand Down
6 changes: 3 additions & 3 deletions scenario/featurecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
12 changes: 6 additions & 6 deletions steps/sampletest/context.go → steps/share/context.go
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions steps/sampletest/steps.go → steps/share/steps.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sampletest
package share

import (
"fmt"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ad5032

Please sign in to comment.