1
1
package sampletest
2
2
3
3
import (
4
+ "errors"
4
5
"fmt"
5
6
identityv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
6
7
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
@@ -14,13 +15,15 @@ import (
14
15
)
15
16
16
17
type CreateShareResult struct {
17
- ShareInfo * identityv1beta1. UserId // Replace with your actual type
18
- Result * collaborationv1beta1. CreateShareResponse // Replace with the actual response type
18
+ ResourceInformation * providerv1beta1. ResourceInfo
19
+ InformationOfSharee * identityv1beta1. UserId
19
20
Status * rpc.Status
20
- Err error
21
+ Error error
21
22
}
22
23
23
- func (f * SampleTestFeatureContext ) userSharesAFileWithTheFollowingUsers (shareer string , resourceName string , sharees * godog.Table ) error {
24
+ var concurentResults []* CreateShareResult
25
+
26
+ func (f * SampleTestFeatureContext ) UserSharesAFileWithTheFollowingUsers (shareer string , resourceName string , sharees * godog.Table ) error {
24
27
ctx , err := f .GetAuthContext (shareer )
25
28
if err != nil {
26
29
return err
@@ -104,7 +107,6 @@ func (f *SampleTestFeatureContext) userSharesAFileWithTheFollowingUsers(shareer
104
107
105
108
for _ , UserId := range collectedShareesInfos {
106
109
wg .Add (1 )
107
-
108
110
go func (UserId * identityv1beta1.UserId ) {
109
111
defer wg .Done ()
110
112
createShareResponse , err := f .Client .CreateShare (
@@ -126,29 +128,37 @@ func (f *SampleTestFeatureContext) userSharesAFileWithTheFollowingUsers(shareer
126
128
)
127
129
128
130
result := CreateShareResult {
129
- ShareInfo : UserId ,
130
- Result : createShareResponse ,
131
- Err : err ,
132
- }
133
-
134
- if err == nil && createShareResponse != nil {
135
- result .Status = createShareResponse .GetStatus ()
131
+ ResourceInformation : resourceInfo ,
132
+ InformationOfSharee : UserId ,
133
+ Status : createShareResponse .GetStatus (),
134
+ Error : err ,
136
135
}
137
136
resultChannel <- result
138
137
139
138
}(UserId )
140
139
}
141
-
142
140
wg .Wait ()
143
141
close (resultChannel )
144
142
145
143
for result := range resultChannel {
146
- if result .Err != nil {
147
- fmt .Printf ("Error for ShareInformation: %+v - %v\n " , result .ShareInfo , result .Err )
148
- } else {
149
- fmt .Printf ("Success for ShareInfo: %+v - Status: %s\n " , result .ShareInfo , result .Status )
150
- }
144
+ concurentResults = append (concurentResults , & CreateShareResult {
145
+ ResourceInformation : result .ResourceInformation ,
146
+ InformationOfSharee : result .InformationOfSharee ,
147
+ Status : result .Status ,
148
+ Error : result .Error ,
149
+ })
151
150
}
152
151
153
152
return nil
154
153
}
154
+
155
+ func (f * SampleTestFeatureContext ) TheConcurrentUserSharingShouldHaveBeenSuccessfull ( ) error {
156
+ for _ , concurentResult := range concurentResults {
157
+ if concurentResult .Status .Code != rpc .Code_CODE_OK || concurentResult .Error != nil {
158
+ err := errors .New ("Could not create share for user with information " + concurentResult .InformationOfSharee .String () + " for the resource " + concurentResult .ResourceInformation .Name )
159
+ fmt .Println (err )
160
+ }
161
+ }
162
+ return nil
163
+ }
164
+
0 commit comments