@@ -37,15 +37,14 @@ type updateTestSetup struct {
3737const (
3838 googleapisTestCommit = "123456"
3939 discoveryTestCommit = "abcdef"
40- conformanceTestCommit = "conformance1234 "
40+ conformanceTestCommit = "protobuf1234 "
4141 protobufTestCommit = "protobuf1234"
4242 showcaseTestCommit = "showcase1234"
4343 googleapisTestTarball = "googleapis-tarball-content"
4444 discoveryTestTarball = "discovery-tarball-content"
45- conformanceTestTarball = "conformance -tarball-content"
45+ conformanceTestTarball = "protobuf -tarball-content"
4646 protobufTestTarball = "protobuf-tarball-content"
4747 showcaseTestTarball = "showcase-tarball-content"
48- testBranch = "other"
4948 unchangedPlaceholder = "this-should-not-change"
5049)
5150
@@ -58,24 +57,19 @@ var (
5857)
5958
6059func setupUpdateTest (t * testing.T , conf * config.Config ) * updateTestSetup {
61- // Source.Branch can be empty in the config file. Update should default to
62- // using the branch configured in [sourceRepos], so we only set up the
63- // test server handlers with Source.Branch when it is explicitly set as it
64- // would be in the file on disk.
65- googleapisBranch := determineBranch ("googleapis" , conf .Sources .Googleapis )
66- discoveryBranch := determineBranch ("discovery" , conf .Sources .Discovery )
67- conformanceBranch := determineBranch ("conformance" , conf .Sources .Conformance )
68- protobufBranch := determineBranch ("protobuf" , conf .Sources .ProtobufSrc )
69- showcaseBranch := determineBranch ("showcase" , conf .Sources .Showcase )
60+ // Update defaults to using the branch configured in [sourceRepos].
61+ // We set up the test server handlers accordingly.
62+ googleapisBranch := sourceRepos ["googleapis" ].Branch
63+ discoveryBranch := sourceRepos ["discovery" ].Branch
64+ protobufBranch := sourceRepos ["protobuf" ].Branch
65+ showcaseBranch := sourceRepos ["showcase" ].Branch
7066
7167 ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
7268 switch r .URL .Path {
7369 case "/repos/googleapis/googleapis/commits/" + googleapisBranch :
7470 w .Write ([]byte (googleapisTestCommit ))
7571 case "/repos/googleapis/discovery-artifact-manager/commits/" + discoveryBranch :
7672 w .Write ([]byte (discoveryTestCommit ))
77- case "/repos/protocolbuffers/protobuf/commits/" + conformanceBranch :
78- w .Write ([]byte (conformanceTestCommit ))
7973 case "/repos/protocolbuffers/protobuf/commits/" + protobufBranch :
8074 w .Write ([]byte (protobufTestCommit ))
8175 case "/repos/googleapis/gapic-showcase/commits/" + showcaseBranch :
@@ -84,8 +78,6 @@ func setupUpdateTest(t *testing.T, conf *config.Config) *updateTestSetup {
8478 w .Write ([]byte (googleapisTestTarball ))
8579 case "/googleapis/discovery-artifact-manager/archive/" + discoveryTestCommit + ".tar.gz" :
8680 w .Write ([]byte (discoveryTestTarball ))
87- case "/protocolbuffers/protobuf/archive/" + conformanceTestCommit + ".tar.gz" :
88- w .Write ([]byte (conformanceTestTarball ))
8981 case "/protocolbuffers/protobuf/archive/" + protobufTestCommit + ".tar.gz" :
9082 w .Write ([]byte (protobufTestTarball ))
9183 case "/googleapis/gapic-showcase/archive/" + showcaseTestCommit + ".tar.gz" :
@@ -106,13 +98,6 @@ func setupUpdateTest(t *testing.T, conf *config.Config) *updateTestSetup {
10698 }
10799}
108100
109- func determineBranch (repoName string , source * config.Source ) string {
110- if source != nil && source .Branch != "" {
111- return source .Branch
112- }
113- return sourceRepos [repoName ].Branch
114- }
115-
116101func setupTestConfig (t * testing.T , conf * config.Config ) string {
117102 if conf == nil {
118103 return ""
@@ -209,20 +194,6 @@ func TestUpdateCommand(t *testing.T) {
209194 cfg .Sources .Discovery .SHA256 = discoveryTestSHA
210195 },
211196 },
212- {
213- name : "googleapis branch" ,
214- args : []string {"librarian" , "update" , "googleapis" },
215- setup : func (cfg * config.Config ) {
216- cfg .Sources .Googleapis .Branch = testBranch
217- cfg .Sources .Googleapis .Commit = "this-should-be-changed"
218- cfg .Sources .Googleapis .SHA256 = "this-should-be-changed"
219- },
220- wantConfig : func (cfg * config.Config ) {
221- cfg .Sources .Googleapis .Branch = testBranch
222- cfg .Sources .Googleapis .Commit = googleapisTestCommit
223- cfg .Sources .Googleapis .SHA256 = googleapisTestSHA
224- },
225- },
226197 } {
227198 t .Run (test .name , func (t * testing.T ) {
228199 initialConfig := updateTestConfig ()
@@ -309,7 +280,6 @@ func updateTestConfig() *config.Config {
309280 SHA256 : unchangedPlaceholder ,
310281 },
311282 ProtobufSrc : & config.Source {
312- Branch : testBranch ,
313283 Commit : unchangedPlaceholder ,
314284 SHA256 : unchangedPlaceholder ,
315285 },
0 commit comments