golang.org/x/build@v0.0.0-20240506185731-218518f32b70/internal/task/gerrit_test.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package task 6 7 import ( 8 "context" 9 "testing" 10 11 "golang.org/x/build/gerrit" 12 wf "golang.org/x/build/internal/workflow" 13 ) 14 15 func TestNoOpCL(t *testing.T) { 16 if !*flagRunVersionTest { 17 t.Skip("Not enabled by flags") 18 } 19 cl := gerrit.NewClient("https://go-review.googlesource.com", gerrit.GitCookiesAuth()) 20 gcl := &RealGerritClient{Client: cl} 21 22 ctx := &wf.TaskContext{Context: context.Background()} 23 changeID, err := gcl.CreateAutoSubmitChange(ctx, gerrit.ChangeInput{ 24 Project: "scratch", 25 Branch: "master", 26 Subject: "no-op CL test", 27 }, nil, map[string]string{"NONEXISTANT_FILE": ""}) 28 if err != nil { 29 t.Fatal(err) 30 } 31 if changeID != "" { 32 t.Fatalf("creating no-op change resulted in a CL %v (%q), wanted none", ChangeLink(changeID), changeID) 33 } 34 }