@@ -160,7 +160,7 @@ func TestRegistryModulesCreate(t *testing.T) {
160
160
assert .Equal (t , * options .Provider , rm .Provider )
161
161
assert .Equal (t , options .RegistryName , rm .RegistryName )
162
162
assert .Equal (t , orgTest .Name , rm .Namespace )
163
- assert .Equal (t , options .NoCode , rm .NoCode )
163
+ assert .Equal (t , options .NoCode , Bool ( rm .NoCode ) )
164
164
165
165
assertRegistryModuleAttributes (t , rm )
166
166
})
@@ -363,6 +363,43 @@ func TestRegistryModuleUpdateWithVCSConnection(t *testing.T) {
363
363
assert .False (t , rm .NoCode )
364
364
})
365
365
366
+ t .Run ("prevents setting the branch when using tag based publishing" , func (t * testing.T ) {
367
+ options := RegistryModuleUpdateOptions {
368
+ VCSRepo : & RegistryModuleVCSRepoUpdateOptions {
369
+ Branch : String ("main" ),
370
+ Tags : Bool (true ),
371
+ },
372
+ }
373
+
374
+ _ , err = client .RegistryModules .Update (ctx , RegistryModuleID {
375
+ Organization : orgTest .Name ,
376
+ Name : rm .Name ,
377
+ Provider : rm .Provider ,
378
+ Namespace : rm .Namespace ,
379
+ RegistryName : rm .RegistryName ,
380
+ }, options )
381
+
382
+ assert .Error (t , err )
383
+ assert .EqualError (t , err , ErrBranchMustBeEmptyWhenTagsEnabled .Error ())
384
+
385
+ options = RegistryModuleUpdateOptions {
386
+ VCSRepo : & RegistryModuleVCSRepoUpdateOptions {
387
+ Branch : String ("" ),
388
+ Tags : Bool (true ),
389
+ },
390
+ }
391
+
392
+ rm , err = client .RegistryModules .Update (ctx , RegistryModuleID {
393
+ Organization : orgTest .Name ,
394
+ Name : rm .Name ,
395
+ Provider : rm .Provider ,
396
+ Namespace : rm .Namespace ,
397
+ RegistryName : rm .RegistryName ,
398
+ }, options )
399
+
400
+ assert .NoError (t , err )
401
+ })
402
+
366
403
t .Run ("toggle between git tag-based and branch-based publishing" , func (t * testing.T ) {
367
404
assert .Equal (t , rm .PublishingMechanism , PublishingMechanismTag )
368
405
@@ -385,7 +422,8 @@ func TestRegistryModuleUpdateWithVCSConnection(t *testing.T) {
385
422
386
423
options = RegistryModuleUpdateOptions {
387
424
VCSRepo : & RegistryModuleVCSRepoUpdateOptions {
388
- Tags : Bool (true ),
425
+ Branch : String ("" ),
426
+ Tags : Bool (true ),
389
427
},
390
428
}
391
429
rm , err = client .RegistryModules .Update (ctx , RegistryModuleID {
@@ -634,7 +672,7 @@ func TestRegistryModulesShowVersion(t *testing.T) {
634
672
rmvRead , errRead := client .RegistryModules .ReadVersion (ctx , registryModuleIDTest , * invalidVersion )
635
673
636
674
require .Error (t , errRead )
637
- assert .Equal (t , ErrResourceNotFound , err )
675
+ assert .Equal (t , ErrResourceNotFound , errRead )
638
676
assert .Empty (t , rmvRead )
639
677
})
640
678
}
@@ -815,6 +853,22 @@ func TestRegistryModulesCreateWithVCSConnection(t *testing.T) {
815
853
assert .Nil (t , rm )
816
854
assert .Equal (t , err , ErrRequiredDisplayIdentifier )
817
855
})
856
+
857
+ t .Run ("when tags are enabled and a branch is provided" , func (t * testing.T ) {
858
+ options := RegistryModuleCreateWithVCSConnectionOptions {
859
+ VCSRepo : & RegistryModuleVCSRepoOptions {
860
+ Identifier : String (githubIdentifier ),
861
+ OAuthTokenID : String (oauthTokenTest .ID ),
862
+ DisplayIdentifier : String (githubIdentifier ),
863
+ Tags : Bool (true ),
864
+ Branch : String ("main" ),
865
+ },
866
+ }
867
+
868
+ rm , err := client .RegistryModules .CreateWithVCSConnection (ctx , options )
869
+ assert .Nil (t , rm )
870
+ assert .Equal (t , err , ErrBranchMustBeEmptyWhenTagsEnabled )
871
+ })
818
872
})
819
873
820
874
t .Run ("without options" , func (t * testing.T ) {
0 commit comments