@@ -63,6 +63,7 @@ func TestUpdateManifestSuccess(t *testing.T) {
6363 if err != nil {
6464 t .Fatal (err )
6565 }
66+ want = nil
6667 if diff := cmp .Diff (want , got ); diff != "" {
6768 t .Errorf ("mismatch (-want, +got):\n %s" , diff )
6869 }
@@ -227,7 +228,7 @@ func TestUpdateManifestBadSidekickConfig(t *testing.T) {
227228 }
228229
229230 if got , err := updateManifest (& release , tag , name ); err == nil {
230- t .Errorf ("expected an error when using a bad version , got=%v" , got )
231+ t .Errorf ("expected an error when using a bad sidekick file , got=%v" , got )
231232 }
232233}
233234
@@ -252,7 +253,7 @@ func TestBumpPackageVersion(t *testing.T) {
252253 }
253254}
254255
255- func TestManifestVersionUpdatedSuccess (t * testing.T ) {
256+ func TestManifestVersionNeedsBumpSuccess (t * testing.T ) {
256257 const tag = "manifest-version-update-success"
257258 requireCommand (t , "git" )
258259 setupForVersionBump (t , tag )
@@ -279,16 +280,43 @@ func TestManifestVersionUpdatedSuccess(t *testing.T) {
279280 t .Fatal (err )
280281 }
281282
282- updated , err := manifestVersionUpdated (& release , tag , name )
283+ needsBump , err := manifestVersionNeedsBump (& release , tag , name )
284+ if err != nil {
285+ t .Fatal (err )
286+ }
287+ if needsBump {
288+ t .Errorf ("expected no need for a bump for %s" , name )
289+ }
290+ }
291+
292+ func TestManifestVersionNeedsBumpNewCrate (t * testing.T ) {
293+ const tag = "manifest-version-update-new-crate"
294+ requireCommand (t , "git" )
295+ setupForVersionBump (t , tag )
296+ release := config.Release {
297+ Remote : "origin" ,
298+ Branch : "main" ,
299+ Preinstalled : map [string ]string {},
300+ }
301+ addGeneratedCrate (t , path .Join ("src" , "new" ), "google-cloud-new" )
302+ if err := external .Run ("git" , "add" , "." ); err != nil {
303+ t .Fatal (err )
304+ }
305+ if err := external .Run ("git" , "commit" , "-m" , "new crate" , "." ); err != nil {
306+ t .Fatal (err )
307+ }
308+ name := path .Join ("src" , "new" , "Cargo.toml" )
309+
310+ needsBump , err := manifestVersionNeedsBump (& release , tag , name )
283311 if err != nil {
284312 t .Fatal (err )
285313 }
286- if ! updated {
287- t .Errorf ("expected a change for %s, got=%v" , name , updated )
314+ if needsBump {
315+ t .Errorf ("no changes for new crates" )
288316 }
289317}
290318
291- func TestManifestVersionUpdatedNoChange (t * testing.T ) {
319+ func TestManifestVersionNeedsBumpNoChange (t * testing.T ) {
292320 const tag = "manifest-version-update-no-change"
293321 requireCommand (t , "git" )
294322 setupForVersionBump (t , tag )
@@ -298,16 +326,16 @@ func TestManifestVersionUpdatedNoChange(t *testing.T) {
298326 Preinstalled : map [string ]string {},
299327 }
300328 name := path .Join ("src" , "storage" , "Cargo.toml" )
301- updated , err := manifestVersionUpdated (& release , tag , name )
329+ needsBump , err := manifestVersionNeedsBump (& release , tag , name )
302330 if err != nil {
303331 t .Fatal (err )
304332 }
305- if updated {
306- t .Errorf ("expected no change for %s, got=%v " , name , updated )
333+ if ! needsBump {
334+ t .Errorf ("expected no change for %s" , name )
307335 }
308336}
309337
310- func TestManifestVersionUpdatedBadDiff (t * testing.T ) {
338+ func TestManifestVersionNeedsBumpBadDiff (t * testing.T ) {
311339 const tag = "manifest-version-update-success"
312340 requireCommand (t , "git" )
313341 setupForVersionBump (t , tag )
@@ -317,7 +345,7 @@ func TestManifestVersionUpdatedBadDiff(t *testing.T) {
317345 Preinstalled : map [string ]string {},
318346 }
319347 name := path .Join ("src" , "storage" , "Cargo.toml" )
320- if updated , err := manifestVersionUpdated (& release , "not-a-valid-tag" , name ); err == nil {
348+ if updated , err := manifestVersionNeedsBump (& release , "not-a-valid-tag" , name ); err == nil {
321349 t .Errorf ("expected an error with an valid tag, got=%v" , updated )
322350 }
323351}
0 commit comments