@@ -21,7 +21,6 @@ import (
2121 "strings"
2222 "testing"
2323
24- "github.com/google/go-cmp/cmp"
2524 cmdtest "github.com/googleapis/librarian/internal/command"
2625 "github.com/googleapis/librarian/internal/config"
2726)
@@ -49,13 +48,8 @@ func TestReleaseAll(t *testing.T) {
4948
5049 checkCargoVersion (t , storageCargo , storageReleased )
5150 checkCargoVersion (t , secretmanagerCargo , secretmanagerReleased )
52- want := map [string ]string {
53- storageName : storageReleased ,
54- secretmanagerName : secretmanagerReleased ,
55- }
56- if diff := cmp .Diff (want , got .Versions ); diff != "" {
57- t .Errorf ("mismatch (-want +got):\n %s" , diff )
58- }
51+ checkLibraryVersion (t , got , storageName , storageReleased )
52+ checkLibraryVersion (t , got , secretmanagerName , secretmanagerReleased )
5953}
6054
6155func TestReleaseOne (t * testing.T ) {
@@ -67,13 +61,8 @@ func TestReleaseOne(t *testing.T) {
6761
6862 checkCargoVersion (t , storageCargo , storageReleased )
6963 checkCargoVersion (t , secretmanagerCargo , secretmanagerInitial )
70- want := map [string ]string {
71- storageName : storageReleased ,
72- secretmanagerName : secretmanagerInitial ,
73- }
74- if diff := cmp .Diff (want , got .Versions ); diff != "" {
75- t .Errorf ("mismatch (-want +got):\n %s" , diff )
76- }
64+ checkLibraryVersion (t , got , storageName , storageReleased )
65+ checkLibraryVersion (t , got , secretmanagerName , secretmanagerInitial )
7766}
7867
7968func setupRelease (t * testing.T ) * config.Config {
@@ -86,9 +75,15 @@ func setupRelease(t *testing.T) *config.Config {
8675 createCrate (t , storageDir , storageName , storageInitial )
8776 createCrate (t , secretmanagerDir , secretmanagerName , secretmanagerInitial )
8877 return & config.Config {
89- Versions : map [string ]string {
90- storageName : storageInitial ,
91- secretmanagerName : secretmanagerInitial ,
78+ Libraries : []* config.Library {
79+ {
80+ Name : storageName ,
81+ Version : storageInitial ,
82+ },
83+ {
84+ Name : secretmanagerName ,
85+ Version : secretmanagerInitial ,
86+ },
9287 },
9388 }
9489}
@@ -122,3 +117,16 @@ func checkCargoVersion(t *testing.T, path, wantVersion string) {
122117 t .Errorf ("%s version mismatch:\n want line: %q\n got:\n %s" , path , wantLine , got )
123118 }
124119}
120+
121+ func checkLibraryVersion (t * testing.T , cfg * config.Config , name , wantVersion string ) {
122+ t .Helper ()
123+ for _ , lib := range cfg .Libraries {
124+ if lib .Name == name {
125+ if lib .Version != wantVersion {
126+ t .Errorf ("library %q version mismatch: want %q, got %q" , name , wantVersion , lib .Version )
127+ }
128+ return
129+ }
130+ }
131+ t .Errorf ("library %q not found in config" , name )
132+ }
0 commit comments