@@ -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,13 +671,12 @@ 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
}
641
678
642
679
func TestRegistryModulesListCommit (t * testing.T ) {
643
- skipUnlessBeta (t )
644
680
githubIdentifier := os .Getenv ("GITHUB_REGISTRY_MODULE_IDENTIFIER" )
645
681
if githubIdentifier == "" {
646
682
t .Skip ("Export a valid GITHUB_REGISTRY_MODULE_IDENTIFIER before running this test" )
@@ -815,6 +851,22 @@ func TestRegistryModulesCreateWithVCSConnection(t *testing.T) {
815
851
assert .Nil (t , rm )
816
852
assert .Equal (t , err , ErrRequiredDisplayIdentifier )
817
853
})
854
+
855
+ t .Run ("when tags are enabled and a branch is provided" , func (t * testing.T ) {
856
+ options := RegistryModuleCreateWithVCSConnectionOptions {
857
+ VCSRepo : & RegistryModuleVCSRepoOptions {
858
+ Identifier : String (githubIdentifier ),
859
+ OAuthTokenID : String (oauthTokenTest .ID ),
860
+ DisplayIdentifier : String (githubIdentifier ),
861
+ Tags : Bool (true ),
862
+ Branch : String ("main" ),
863
+ },
864
+ }
865
+
866
+ rm , err := client .RegistryModules .CreateWithVCSConnection (ctx , options )
867
+ assert .Nil (t , rm )
868
+ assert .Equal (t , err , ErrBranchMustBeEmptyWhenTagsEnabled )
869
+ })
818
870
})
819
871
820
872
t .Run ("without options" , func (t * testing.T ) {
0 commit comments