build(internal/librarianops/upgrade): add version config file updater#3926
build(internal/librarianops/upgrade): add version config file updater#3926miguelvelezsa wants to merge 5 commits intoupgrade-version-fetcherfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces new functionality to update the version in a librarian.yaml file, along with corresponding tests. The implementation is straightforward and the tests are well-written, covering the main success and failure scenarios. I have provided a suggestion to improve the code's clarity by correcting a function comment to accurately reflect its behavior.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: miguel <miguelvelezsa@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## upgrade-version-fetcher #3926 +/- ##
===========================================================
+ Coverage 81.84% 81.87% +0.03%
===========================================================
Files 72 73 +1
Lines 6273 6285 +12
===========================================================
+ Hits 5134 5146 +12
Misses 791 791
Partials 348 348 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| // UpdateLibrarianVersion updates the version field in the librarian.yaml config file with the provided version. | ||
| // If the file does not exist, returns an error. | ||
| func UpdateLibrarianVersion(version, configPath string) error { |
There was a problem hiding this comment.
I think you can just use repoPath as an input and remove GenerateLibrarianConfigPath and getConfigFile, since they seem very straightforward.
There was a problem hiding this comment.
librarian/internal/librarianops/generate.go
Line 222 in e20ee88
| } | ||
| } | ||
|
|
||
| func TestGetConfigFile(t *testing.T) { |
There was a problem hiding this comment.
Could you review https://github.com/googleapis/librarian/blob/main/doc/howwewritego.md#writing-tests to refactor the tests?
| @@ -0,0 +1,49 @@ | |||
| // Copyright 2026 Google LLC | |||
There was a problem hiding this comment.
ditto re: put this in internal/librarianops/upgrade.go as opposed to a separate package
| t.Fatalf("failed to write initial config file: %v", err) | ||
| } | ||
|
|
||
| t.Run("Success", func(t *testing.T) { |
There was a problem hiding this comment.
Make these two separate tests
TestUpdateLibrarianVersion and TestUpdateLibrarianVersion_Error
[2 of 4]
Create librarian_config_updater file. File consist in the function to update a librarian.yaml config file.
Second step in #3911.