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