@@ -24,6 +24,7 @@ import (
2424
2525 "github.com/google/go-cmp/cmp"
2626 "github.com/googleapis/librarian/internal/config"
27+ "github.com/googleapis/librarian/internal/repometadata"
2728 sidekickconfig "github.com/googleapis/librarian/internal/sidekick/config"
2829 "github.com/googleapis/librarian/internal/testhelper"
2930)
@@ -70,7 +71,7 @@ func TestGenerateVeneer(t *testing.T) {
7071 sources := & sidekickconfig.Sources {
7172 Googleapis : googleapisDir ,
7273 }
73- if err := generate (t .Context (), library , sources ); err != nil {
74+ if err := generate (t .Context (), & config. Config { Language : "rust" , Repo : "google-cloud-rust" }, library , sources ); err != nil {
7475 t .Fatal (err )
7576 }
7677
@@ -175,7 +176,7 @@ func TestGenerateVeneerNoModules(t *testing.T) {
175176 sources := & sidekickconfig.Sources {
176177 Googleapis : googleapisDir ,
177178 }
178- if err := generate (t .Context (), library , sources ); err != nil {
179+ if err := generate (t .Context (), & config. Config { Language : "rust" , Repo : "google-cloud-rust" }, library , sources ); err != nil {
179180 t .Fatal (err )
180181 }
181182
@@ -323,7 +324,8 @@ func TestGenerateLibraries(t *testing.T) {
323324 library .Output = filepath .Join ("generated" , library .Name )
324325 }
325326
326- if err := GenerateLibraries (t .Context (), libraries , sources ); err != nil {
327+ cfg := & config.Config {Language : "rust" , Repo : "google-cloud-rust" }
328+ if err := GenerateLibraries (t .Context (), cfg , libraries , sources ); err != nil {
327329 t .Fatal (err )
328330 }
329331 // Just check that a Cargo.toml has been created for each library.
@@ -381,7 +383,8 @@ func TestGenerateLibraries_Error(t *testing.T) {
381383 }
382384 t .Chdir (workspaceDir )
383385
384- gotErr := GenerateLibraries (t .Context (), libraries , sources )
386+ cfg := & config.Config {Language : "rust" , Repo : "google-cloud-rust" }
387+ gotErr := GenerateLibraries (t .Context (), cfg , libraries , sources )
385388 wantErrMessage := "unknown specification format \" invalid\" "
386389 if gotErr == nil {
387390 t .Fatalf ("expected error with message %s" , wantErrMessage )
@@ -472,7 +475,7 @@ func TestGenerate(t *testing.T) {
472475 sources := & sidekickconfig.Sources {
473476 Googleapis : googleapisDir ,
474477 }
475- if err := generate (t .Context (), library , sources ); err != nil {
478+ if err := generate (t .Context (), & config. Config { Language : "rust" , Repo : "google-cloud-rust" }, library , sources ); err != nil {
476479 t .Fatal (err )
477480 }
478481
@@ -485,6 +488,7 @@ func TestGenerate(t *testing.T) {
485488 {filepath .Join (outDir , "README.md" ), "# Google Cloud Client Libraries for Rust - Secret Manager API" },
486489 {filepath .Join (outDir , "src" , "lib.rs" ), "pub mod model;" },
487490 {filepath .Join (outDir , "src" , "lib.rs" ), "pub mod client;" },
491+ {filepath .Join (outDir , ".repo-metadata.json" ), "secretmanager.googleapis.com" },
488492 } {
489493 t .Run (check .path , func (t * testing.T ) {
490494 if _ , err := os .Stat (check .path ); err != nil {
@@ -610,3 +614,51 @@ func TestFindModuleByOutput(t *testing.T) {
610614 })
611615 }
612616}
617+ func TestCreateRepoMetadata (t * testing.T ) {
618+ googleapisDir , err := filepath .Abs ("../../testdata/googleapis" )
619+ if err != nil {
620+ t .Fatal (err )
621+ }
622+ cfg := & config.Config {
623+ Language : config .LanguageRust ,
624+ Repo : "googleapis/google-cloud-rust" ,
625+ }
626+ library := & config.Library {
627+ Name : "google-cloud-secretmanager-v1" ,
628+ Version : "0.1.0" ,
629+ ReleaseLevel : "preview" ,
630+ APIs : []* config.API {
631+ {
632+ Path : "google/cloud/secretmanager/v1" ,
633+ },
634+ },
635+ }
636+ sources := & sidekickconfig.Sources {
637+ Googleapis : googleapisDir ,
638+ }
639+
640+ got , err := createRepoMetadata (cfg , library , sources )
641+ if err != nil {
642+ t .Fatal (err )
643+ }
644+
645+ want := & repometadata.RepoMetadata {
646+ Name : "" ,
647+ NamePretty : "Secret Manager API" ,
648+ ProductDocumentation : "" ,
649+ ClientDocumentation : "https://docs.rs/google-cloud-secretmanager-v1/latest" ,
650+ IssueTracker : "" ,
651+ ReleaseLevel : "preview" ,
652+ Language : config .LanguageRust ,
653+ Repo : "googleapis/google-cloud-rust" ,
654+ DistributionName : "google-cloud-rust" ,
655+ APIID : "secretmanager.googleapis.com" ,
656+ APIShortname : "secretmanager" ,
657+ APIDescription : "" ,
658+ LibraryType : "GAPIC_AUTO" ,
659+ }
660+
661+ if diff := cmp .Diff (want , got ); diff != "" {
662+ t .Errorf ("mismatch (-want +got):\n %s" , diff )
663+ }
664+ }
0 commit comments