go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/resultdb/internal/testutil/invocation.go (about) 1 // Copyright 2023 The LUCI Authors. 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 // http://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 testutil 16 17 import ( 18 pb "go.chromium.org/luci/resultdb/proto/v1" 19 20 "google.golang.org/protobuf/types/known/structpb" 21 ) 22 23 func TestProperties() *structpb.Struct { 24 return &structpb.Struct{ 25 Fields: map[string]*structpb.Value{ 26 "key_1": structpb.NewStringValue("value_1"), 27 "key_2": structpb.NewStructValue(&structpb.Struct{ 28 Fields: map[string]*structpb.Value{ 29 "child_key": structpb.NewNumberValue(1), 30 }, 31 }), 32 }, 33 } 34 } 35 36 func TestSources() *pb.Sources { 37 return TestSourcesWithChangelistNumbers(567) 38 } 39 40 func TestSourcesWithChangelistNumbers(changelistNumbers ...int) *pb.Sources { 41 result := &pb.Sources{ 42 GitilesCommit: &pb.GitilesCommit{ 43 Host: "chromium.googlesource.com", 44 Project: "infra/infra", 45 Ref: "refs/heads/main", 46 CommitHash: "1234567890abcdefabcd1234567890abcdefabcd", 47 Position: 12345, 48 }, 49 IsDirty: true, 50 } 51 for _, cl := range changelistNumbers { 52 result.Changelists = append(result.Changelists, &pb.GerritChange{ 53 Host: "chromium-review.googlesource.com", 54 Project: "infra/luci-go", 55 Change: int64(cl), 56 Patchset: 321, 57 }) 58 } 59 return result 60 }