@@ -743,58 +743,39 @@ func TestHasRESTNumericEnums(t *testing.T) {
743743
744744func TestReleaseLevel (t * testing.T ) {
745745 for _ , test := range []struct {
746- name string
747- apiPath string
748- version string
749- want string
746+ name string
747+ sc * serviceconfig.API
748+ want string
750749 }{
751750 {
752- name : "ga" ,
753- apiPath : "google/cloud/secretmanager/v1" ,
754- version : "1.0.0" ,
755- want : "ga" ,
756- },
757- {
758- name : "stable with pre-GA version" ,
759- apiPath : "google/cloud/secretmanager/v1" ,
760- version : "0.11.0" ,
761- want : "beta" ,
762- },
763- {
764- name : "alpha" ,
765- apiPath : "google/cloud/secretmanager/v1alpha1" ,
766- want : "alpha" ,
767- },
768- {
769- name : "beta" ,
770- apiPath : "google/cloud/secretmanager/v1beta2" ,
771- want : "beta" ,
751+ name : "empty release levels" ,
752+ sc : & serviceconfig.API {},
753+ want : "ga" ,
772754 },
773755 {
774- name : "alpha in api path" ,
775- apiPath : "google/cloud/alphabet/v1" ,
776- version : "1.0.0" ,
777- want : "ga" ,
756+ name : "release levels do not have go" ,
757+ sc : & serviceconfig.API {
758+ ReleaseLevels : map [string ]string {config .LanguagePython : "beta" },
759+ },
760+ want : "ga" ,
778761 },
779762 {
780- name : "empty version" ,
781- apiPath : "google/cloud/alphabet/v1" ,
782- version : "" ,
783- want : "alpha" ,
763+ name : "alpha" ,
764+ sc : & serviceconfig.API {
765+ ReleaseLevels : map [string ]string {config .LanguageGo : "alpha" },
766+ },
767+ want : "alpha" ,
784768 },
785769 {
786- name : "empty version with beta path" ,
787- apiPath : "google/cloud/alphabet/v1beta1" ,
788- version : "" ,
789- want : "beta" ,
770+ name : "beta" ,
771+ sc : & serviceconfig.API {
772+ ReleaseLevels : map [string ]string {config .LanguageGo : "beta" },
773+ },
774+ want : "beta" ,
790775 },
791776 } {
792777 t .Run (test .name , func (t * testing.T ) {
793- got , err := releaseLevel (test .apiPath , test .version )
794- if err != nil {
795- t .Error (err )
796- return
797- }
778+ got := releaseLevel (test .sc )
798779 if diff := cmp .Diff (test .want , got ); diff != "" {
799780 t .Errorf ("mismatch (-want +got):\n %s" , diff )
800781 }
@@ -850,18 +831,13 @@ func TestBuildGAPICOpts(t *testing.T) {
850831 for _ , test := range []struct {
851832 name string
852833 apiPath string
853- library * config.Library
854834 goAPI * config.GoAPI
855835 googleapisDir string
856836 want []string
857837 }{
858838 {
859839 name : "basic case with service and grpc configs" ,
860840 apiPath : "google/cloud/secretmanager/v1" ,
861- library : & config.Library {
862- Name : "secretmanager" ,
863- Version : "1.2.3" ,
864- },
865841 goAPI : & config.GoAPI {
866842 ClientPackage : "secretmanager" ,
867843 ImportPath : "secretmanager/apiv1" ,
@@ -881,10 +857,6 @@ func TestBuildGAPICOpts(t *testing.T) {
881857 {
882858 name : "no rest numeric enums" ,
883859 apiPath : "google/cloud/bigquery/v2" ,
884- library : & config.Library {
885- Name : "bigquery/v2" ,
886- Version : "1.2.3" ,
887- },
888860 goAPI : & config.GoAPI {
889861 ClientPackage : "bigquery" ,
890862 ImportPath : "bigquery/v2/apiv2" ,
@@ -897,39 +869,12 @@ func TestBuildGAPICOpts(t *testing.T) {
897869 "api-service-config=" + filepath .Join (googleapisDir , "google/cloud/bigquery/v2/bigquery_v2.yaml" ),
898870 "grpc-service-config=" + filepath .Join (googleapisDir , "google/cloud/bigquery/v2/bigquery_grpc_service_config.json" ),
899871 "transport=grpc+rest" ,
900- "release-level=ga" ,
901- },
902- },
903- {
904- name : "beta release level from version" ,
905- apiPath : "google/cloud/secretmanager/v1" ,
906- library : & config.Library {
907- Name : "secretmanager" ,
908- Version : "0.2.3" ,
909- },
910- goAPI : & config.GoAPI {
911- ClientPackage : "secretmanager" ,
912- ImportPath : "secretmanager/apiv1" ,
913- Path : "google/cloud/secretmanager/v1" ,
914- },
915- googleapisDir : googleapisDir ,
916- want : []string {
917- "go-gapic-package=cloud.google.com/go/secretmanager/apiv1;secretmanager" ,
918- "metadata" ,
919- "rest-numeric-enums" ,
920- "api-service-config=" + filepath .Join (googleapisDir , "google/cloud/secretmanager/v1/secretmanager_v1.yaml" ),
921- "grpc-service-config=" + filepath .Join (googleapisDir , "google/cloud/secretmanager/v1/secretmanager_grpc_service_config.json" ),
922- "transport=grpc+rest" ,
923- "release-level=beta" ,
872+ "release-level=alpha" ,
924873 },
925874 },
926875 {
927876 name : "transport override" ,
928877 apiPath : "google/cloud/gkehub/v1" ,
929- library : & config.Library {
930- Name : "gkehub" ,
931- Version : "1.2.3" ,
932- },
933878 goAPI : & config.GoAPI {
934879 ClientPackage : "gkehub" ,
935880 ImportPath : "gkehub/apiv1" ,
@@ -948,10 +893,6 @@ func TestBuildGAPICOpts(t *testing.T) {
948893 {
949894 name : "no metadata" ,
950895 apiPath : "google/cloud/gkehub/v1" ,
951- library : & config.Library {
952- Name : "gkehub" ,
953- Version : "1.2.3" ,
954- },
955896 goAPI : & config.GoAPI {
956897 ClientPackage : "gkehub" ,
957898 ImportPath : "gkehub/apiv1" ,
@@ -970,11 +911,6 @@ func TestBuildGAPICOpts(t *testing.T) {
970911 {
971912 name : "generator features" ,
972913 apiPath : "google/cloud/bigquery/v2" ,
973- library : & config.Library {
974- Name : "bigquery/v2" ,
975- Version : "1.2.3" ,
976- APIs : []* config.API {{Path : "google/cloud/bigquery/v2" }},
977- },
978914 goAPI : & config.GoAPI {
979915 ClientPackage : "bigquery" ,
980916 EnabledGeneratorFeatures : []string {"F_wrapper_types_for_page_size" },
@@ -989,17 +925,12 @@ func TestBuildGAPICOpts(t *testing.T) {
989925 "api-service-config=" + filepath .Join (googleapisDir , "google/cloud/bigquery/v2/bigquery_v2.yaml" ),
990926 "grpc-service-config=" + filepath .Join (googleapisDir , "google/cloud/bigquery/v2/bigquery_grpc_service_config.json" ),
991927 "transport=grpc+rest" ,
992- "release-level=ga " ,
928+ "release-level=alpha " ,
993929 },
994930 },
995931 {
996932 name : "no transport" ,
997933 apiPath : "google/cloud/apigeeconnect/v1" ,
998- library : & config.Library {
999- Name : "apigeeconnect" ,
1000- Version : "1.2.3" ,
1001- APIs : []* config.API {{Path : "google/cloud/apigeeconnect/v1" }},
1002- },
1003934 goAPI : & config.GoAPI {
1004935 ClientPackage : "apigeeconnect" ,
1005936 ImportPath : "apigeeconnect/apiv1" ,
@@ -1017,11 +948,6 @@ func TestBuildGAPICOpts(t *testing.T) {
1017948 {
1018949 name : "diregapic" ,
1019950 apiPath : "google/cloud/compute/v1" ,
1020- library : & config.Library {
1021- Name : "compute" ,
1022- Version : "1.2.3" ,
1023- APIs : []* config.API {{Path : "google/cloud/compute/v1" }},
1024- },
1025951 goAPI : & config.GoAPI {
1026952 ClientPackage : "compute" ,
1027953 ImportPath : "compute/apiv1" ,
@@ -1041,7 +967,7 @@ func TestBuildGAPICOpts(t *testing.T) {
1041967 } {
1042968 t .Run (test .name , func (t * testing.T ) {
1043969 t .Parallel ()
1044- got , err := buildGAPICOpts (test .apiPath , test .library , test . goAPI , test .googleapisDir )
970+ got , err := buildGAPICOpts (test .apiPath , test .goAPI , test .googleapisDir )
1045971 if err != nil {
1046972 t .Fatal (err )
1047973 }
0 commit comments