@@ -762,6 +762,86 @@ func TestRegistryModulesCreateBranchBasedWithVCSConnection(t *testing.T) {
762
762
})
763
763
}
764
764
765
+ func TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting (t * testing.T ) {
766
+ skipUnlessBeta (t )
767
+
768
+ githubIdentifier := os .Getenv ("GITHUB_REGISTRY_MODULE_IDENTIFIER" )
769
+ if githubIdentifier == "" {
770
+ t .Skip ("Export a valid GITHUB_REGISTRY_MODULE_IDENTIFIER before running this test" )
771
+ }
772
+ repositoryName := strings .Split (githubIdentifier , "/" )[1 ]
773
+ registryModuleProvider := strings .SplitN (repositoryName , "-" , 3 )[1 ]
774
+ registryModuleName := strings .SplitN (repositoryName , "-" , 3 )[2 ]
775
+
776
+ githubBranch := os .Getenv ("GITHUB_REGISTRY_MODULE_BRANCH" )
777
+ if githubBranch == "" {
778
+ githubBranch = "main"
779
+ }
780
+
781
+ client := testClient (t )
782
+ ctx := context .Background ()
783
+
784
+ orgTest , orgTestCleanup := createOrganization (t , client )
785
+ defer orgTestCleanup ()
786
+
787
+ oauthTokenTest , oauthTokenTestCleanup := createOAuthToken (t , client , orgTest )
788
+ defer oauthTokenTestCleanup ()
789
+
790
+ t .Run ("with valid options" , func (t * testing.T ) {
791
+ options := RegistryModuleCreateWithVCSConnectionOptions {
792
+ VCSRepo : & RegistryModuleVCSRepoOptions {
793
+ OrganizationName : String (orgTest .Name ),
794
+ Identifier : String (githubIdentifier ),
795
+ OAuthTokenID : String (oauthTokenTest .ID ),
796
+ DisplayIdentifier : String (githubIdentifier ),
797
+ Branch : String (githubBranch ),
798
+ },
799
+ TestConfig : & RegistryModuleTestConfigOptions {
800
+ TestsEnabled : Bool (true ),
801
+ },
802
+ }
803
+ rm , err := client .RegistryModules .CreateWithVCSConnection (ctx , options )
804
+ require .NoError (t , err )
805
+ assert .NotEmpty (t , rm .ID )
806
+ assert .Equal (t , registryModuleName , rm .Name )
807
+ assert .Equal (t , registryModuleProvider , rm .Provider )
808
+ assert .Equal (t , githubBranch , rm .VCSRepo .Branch )
809
+
810
+ t .Run ("tests are enabled" , func (t * testing.T ) {
811
+ assert .NotEmpty (t , rm .TestConfig )
812
+ assert .True (t , rm .TestConfig .TestsEnabled )
813
+ })
814
+ })
815
+
816
+ t .Run ("with invalid options" , func (t * testing.T ) {
817
+ options := RegistryModuleCreateWithVCSConnectionOptions {
818
+ VCSRepo : & RegistryModuleVCSRepoOptions {
819
+ Identifier : String (githubIdentifier ),
820
+ OAuthTokenID : String (oauthTokenTest .ID ),
821
+ DisplayIdentifier : String (githubIdentifier ),
822
+ Branch : String (githubBranch ),
823
+ },
824
+ }
825
+ _ , err := client .RegistryModules .CreateWithVCSConnection (ctx , options )
826
+ require .Equal (t , err , ErrInvalidOrg )
827
+
828
+ t .Run ("when the the module is not branch based and test are enabled" , func (t * testing.T ) {
829
+ options := RegistryModuleCreateWithVCSConnectionOptions {
830
+ VCSRepo : & RegistryModuleVCSRepoOptions {
831
+ Identifier : String (githubIdentifier ),
832
+ OAuthTokenID : String (oauthTokenTest .ID ),
833
+ DisplayIdentifier : String (githubIdentifier ),
834
+ },
835
+ TestConfig : & RegistryModuleTestConfigOptions {
836
+ TestsEnabled : Bool (true ),
837
+ },
838
+ }
839
+ _ , err := client .RegistryModules .CreateWithVCSConnection (ctx , options )
840
+ require .Equal (t , err , ErrRequiredBranchWhenTestsEnabled )
841
+ })
842
+ })
843
+ }
844
+
765
845
func TestRegistryModulesCreateWithGithubApp (t * testing.T ) {
766
846
githubIdentifier := os .Getenv ("GITHUB_REGISTRY_MODULE_IDENTIFIER" )
767
847
if githubIdentifier == "" {
0 commit comments