Skip to content

Commit ba88c5f

Browse files
authored
refactor(internal/sample): export LibrarianVersion constant (#3812)
Move the constant testLibrarianVersion to internal/sample, and use sample.LibrarianVersion throughout tests. Fixes #3793
1 parent f9ff352 commit ba88c5f

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

internal/librarian/tidy_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ import (
2323

2424
"github.com/google/go-cmp/cmp"
2525
"github.com/googleapis/librarian/internal/config"
26+
"github.com/googleapis/librarian/internal/sample"
2627
"github.com/googleapis/librarian/internal/yaml"
2728
)
2829

29-
const testLibrarianVersion = "v0.1.0"
30-
3130
func TestValidateLibraries(t *testing.T) {
3231
for _, test := range []struct {
3332
name string
@@ -175,7 +174,7 @@ libraries:
175174
version: "1.0.0"
176175
- name: google-cloud-bigquery-v1
177176
version: "2.0.0"
178-
`, testLibrarianVersion)
177+
`, sample.LibrarianVersion)
179178
if err := os.WriteFile(configPath, []byte(configContent), 0644); err != nil {
180179
t.Fatal(err)
181180
}
@@ -187,8 +186,8 @@ libraries:
187186
if err != nil {
188187
t.Fatal(err)
189188
}
190-
if cfg.Version != testLibrarianVersion {
191-
t.Errorf("version = %q, want %q", cfg.Version, testLibrarianVersion)
189+
if cfg.Version != sample.LibrarianVersion {
190+
t.Errorf("version = %q, want %q", cfg.Version, sample.LibrarianVersion)
192191
}
193192

194193
var got []string

internal/librarianops/librarianops_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ import (
2929
"github.com/googleapis/librarian/internal/yaml"
3030
)
3131

32-
const testLibrarianVersion = "v0.1.0"
33-
3432
func TestGenerateCommand(t *testing.T) {
3533
for _, test := range []struct {
3634
name string
@@ -158,13 +156,13 @@ func TestUpdateLibrarianVersion(t *testing.T) {
158156
configPath := filepath.Join(repoDir, "librarian.yaml")
159157
initialConfig := &config.Config{
160158
Language: "rust",
161-
Version: "v0.1.0",
159+
Version: sample.LibrarianVersion,
162160
}
163161
if err := yaml.Write(configPath, initialConfig); err != nil {
164162
t.Fatal(err)
165163
}
166164

167-
newVersion := testLibrarianVersion
165+
newVersion := "v0.2.0"
168166
if err := updateLibrarianVersion(newVersion, repoDir); err != nil {
169167
t.Fatal(err)
170168
}

internal/sample/sample.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
)
2424

2525
const (
26+
// LibrarianVersion is the librarian version used in [Config].
27+
LibrarianVersion = "v0.1.0"
2628
// Lib1Name is the name of the first library added to the [Config].
2729
Lib1Name = "google-cloud-storage"
2830
// Lib2Name is the name of the second library added to the [Config].
@@ -71,7 +73,7 @@ var (
7173
func Config() *config.Config {
7274
return &config.Config{
7375
Language: "fake",
74-
Version: "v0.1.0",
76+
Version: LibrarianVersion,
7577
Default: &config.Default{},
7678
Release: &config.Release{
7779
Remote: "origin",

0 commit comments

Comments
 (0)