File tree Expand file tree Collapse file tree 5 files changed +79
-32
lines changed Expand file tree Collapse file tree 5 files changed +79
-32
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2025 Google LLC
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // https://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ package rustrelease
16+
17+ import "github.com/googleapis/librarian/internal/sidekick/internal/config"
18+
19+ // BumpVersions finds all the crates that need a version bump and performs the
20+ // bump, changing both the Cargo.toml and sidekick.toml files.
21+ func BumpVersions (config * config.Release ) error {
22+ if err := PreFlight (config ); err != nil {
23+ return err
24+ }
25+ return nil
26+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2025 Google LLC
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // https://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ package rustrelease
16+
17+ import (
18+ "testing"
19+
20+ "github.com/googleapis/librarian/internal/sidekick/internal/config"
21+ )
22+
23+ func TestBumpVersionsSuccess (t * testing.T ) {
24+ requireCommand (t , "git" )
25+ config := & config.Release {
26+ Preinstalled : map [string ]string {
27+ "git" : "git" ,
28+ "cargo" : "git" ,
29+ },
30+ }
31+ if err := BumpVersions (config ); err != nil {
32+ t .Fatal (err )
33+ }
34+ }
35+
36+ func TestBumpVersionsPreflightError (t * testing.T ) {
37+ config := & config.Release {
38+ Preinstalled : map [string ]string {
39+ "git" : "git-not-found" ,
40+ },
41+ }
42+ if err := BumpVersions (config ); err == nil {
43+ t .Errorf ("expected an error in BumpVersions() with a bad git command" )
44+ }
45+ }
Original file line number Diff line number Diff line change @@ -36,10 +36,7 @@ effect.
3636 )
3737}
3838
39- // rustGenerate increments the version numbers as needed.
39+ // rustBumpVersions increments the version numbers as needed.
4040func rustBumpVersions (rootConfig * config.Config , cmdLine * CommandLine ) error {
41- if err := rustrelease .PreFlight (rootConfig .Release ); err != nil {
42- return err
43- }
44- return nil
41+ return rustrelease .BumpVersions (rootConfig .Release )
4542}
Original file line number Diff line number Diff line change @@ -20,33 +20,16 @@ import (
2020 "github.com/googleapis/librarian/internal/sidekick/internal/config"
2121)
2222
23- func TestPreflightSuccess (t * testing.T ) {
24- requireGit (t )
25- config := config.Config {
23+ func TestRustBumpVersions (t * testing.T ) {
24+ config := & config.Config {
2625 Release : & config.Release {
2726 Preinstalled : map [string ]string {
28- "git" : "git" ,
29- "cargo" : "git" ,
27+ "git" : "git-not-found" ,
3028 },
3129 },
3230 }
33- cmdLine := CommandLine {}
34- if err := rustBumpVersions (& config , & cmdLine ); err != nil {
35- t .Fatal (err )
36- }
37- }
38-
39- func TestPreflightMissingCommand (t * testing.T ) {
40- requireGit (t )
41- config := config.Config {
42- Release : & config.Release {
43- Preinstalled : map [string ]string {
44- "cargo" : "not-a-valid-command-bad-bad" ,
45- },
46- },
47- }
48- cmdLine := CommandLine {}
49- if err := rustBumpVersions (& config , & cmdLine ); err == nil {
50- t .Errorf ("expected an error in rustBumpVersions() with a bad cargo command" )
31+ cmdLine := & CommandLine {}
32+ if err := rustBumpVersions (config , cmdLine ); err == nil {
33+ t .Errorf ("expected an error with invalid git command" )
5134 }
5235}
Original file line number Diff line number Diff line change @@ -49,7 +49,3 @@ func requireProtoc(t *testing.T) {
4949func requireCargo (t * testing.T ) {
5050 requireCommand (t , "cargo" )
5151}
52-
53- func requireGit (t * testing.T ) {
54- requireCommand (t , "git" )
55- }
You can’t perform that action at this time.
0 commit comments