99 "runtime"
1010 "testing"
1111
12+ "github.com/google/uuid"
1213 "github.com/stretchr/testify/assert"
1314 sdk "github.com/trinsic-id/sdk/go/proto"
14- "google.golang.org/grpc"
1515)
1616
1717// pathData() {
@@ -63,11 +63,6 @@ func TestServiceOptions(t *testing.T) {
6363func TestVaccineCredentialsDemo (t * testing.T ) {
6464 assert2 := assert .New (t )
6565
66- err := createDefaultEcosystem ()
67- if ! assert2 .Nil (err ) {
68- return
69- }
70-
7166 // Open in background
7267 opts , err := NewServiceOptions (WithTestEnv ())
7368 if ! assert2 .Nil (err ) {
@@ -79,8 +74,6 @@ func TestVaccineCredentialsDemo(t *testing.T) {
7974 return
8075 }
8176
82- opts .Channel = accountService .GetChannel ()
83-
8477 // if !accountService.GetChannel().WaitForStateChange(context.Background(), connectivity.Ready) {
8578 // t.Fail()
8679 // }
@@ -180,12 +173,12 @@ func TestVaccineCredentialsDemo(t *testing.T) {
180173}
181174
182175func TestTrustRegistryDemo (t * testing.T ) {
183- assert2 , channel , authtoken , err := createAccountAndSignIn (t )
176+ assert2 , authtoken , err := createAccountAndSignIn (t )
184177 if ! assert2 .Nil (err ) {
185178 return
186179 }
187180
188- opts , err := NewServiceOptions (WithTestEnv (), WithAuthToken (authtoken ), WithChannel ( channel ) )
181+ opts , err := NewServiceOptions (WithTestEnv (), WithAuthToken (authtoken ))
189182 if ! assert2 .Nil (err ) {
190183 return
191184 }
@@ -242,26 +235,26 @@ func TestTrustRegistryDemo(t *testing.T) {
242235 assert2 .NotEmpty (ecosystemList )
243236}
244237
245- func createAccountAndSignIn (t * testing.T ) (* assert.Assertions , * grpc. ClientConn , string , error ) {
238+ func createAccountAndSignIn (t * testing.T ) (* assert.Assertions , string , error ) {
246239 assert2 := assert .New (t )
247240 opts , err := NewServiceOptions (WithTestEnv ())
248241 if ! assert2 .Nil (err ) {
249- return assert2 , nil , "" , err
242+ return assert2 , "" , err
250243 }
251244 // Open in background
252245 accountService , err := NewAccountService (opts )
253246 if ! assert2 .Nil (err ) {
254- return assert2 , nil , "" , err
247+ return assert2 , "" , err
255248 }
256249 authtoken , _ , err := accountService .SignIn (context .Background (), & sdk.SignInRequest {})
257250 if ! assert2 .Nil (err ) {
258251 fmt .Println (err )
259- return assert2 , nil , "" , err
252+ return assert2 , "" , err
260253 }
261- return assert2 , accountService . GetChannel (), authtoken , nil
254+ return assert2 , authtoken , nil
262255}
263256
264- func createDefaultEcosystem () error {
257+ func createRandomEcosystem () error {
265258 opts , err := NewServiceOptions (WithTestEnv ())
266259 if err != nil {
267260 return err
@@ -272,17 +265,17 @@ func createDefaultEcosystem() error {
272265 return err
273266 }
274267
275- _ , err = ps .CreateEcosystem (context .Background (), & sdk.CreateEcosystemRequest {Name : "default" })
268+ _ , err = ps .CreateEcosystem (context .Background (), & sdk.CreateEcosystemRequest {Name : "test-sdk-" + uuid . New (). String () })
276269
277270 return err
278271}
279272func TestEcosystemDemo (t * testing.T ) {
280- assert2 , channel , authtoken , err := createAccountAndSignIn (t )
273+ assert2 , authtoken , err := createAccountAndSignIn (t )
281274 if ! assert2 .Nil (err ) {
282275 return
283276 }
284277
285- opts , err := NewServiceOptions (WithTestEnv (), WithAuthToken (authtoken ), WithChannel ( channel ) )
278+ opts , err := NewServiceOptions (WithTestEnv (), WithAuthToken (authtoken ))
286279 if ! assert2 .Nil (err ) {
287280 return
288281 }
@@ -293,7 +286,7 @@ func TestEcosystemDemo(t *testing.T) {
293286 }
294287
295288 actualCreate , err := service .CreateEcosystem (context .Background (), & sdk.CreateEcosystemRequest {
296- Name : "Test-Ecosystem" ,
289+ Name : "test-sdk-" + uuid . New (). String () ,
297290 Description : "My ecosystem" ,
298291 Uri : "https://example.com" ,
299292 })
@@ -314,12 +307,12 @@ func TestEcosystemDemo(t *testing.T) {
314307}
315308
316309func TestTemplatesDemo (t * testing.T ) {
317- assert2 , channel , authtoken , err := createAccountAndSignIn (t )
310+ assert2 , authtoken , err := createAccountAndSignIn (t )
318311 if ! assert2 .Nil (err ) {
319312 return
320313 }
321314
322- opts , err := NewServiceOptions (WithTestEnv (), WithAuthToken (authtoken ), WithChannel ( channel ) )
315+ opts , err := NewServiceOptions (WithTestEnv (), WithAuthToken (authtoken ))
323316 if ! assert2 .Nil (err ) {
324317 return
325318 }
0 commit comments