go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/analysis/internal/changepoints/testutil/testutil.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 contains utility functions for tests. 16 package testutil 17 18 import ( 19 "time" 20 21 "google.golang.org/protobuf/types/known/timestamppb" 22 23 controlpb "go.chromium.org/luci/analysis/internal/ingestion/control/proto" 24 "go.chromium.org/luci/analysis/internal/tasks/taskspb" 25 configpb "go.chromium.org/luci/analysis/proto/config" 26 pb "go.chromium.org/luci/analysis/proto/v1" 27 ) 28 29 func SamplePayload() *taskspb.IngestTestResults { 30 return &taskspb.IngestTestResults{ 31 Build: &controlpb.BuildResult{ 32 Id: 1234, 33 Project: "chromium", 34 }, 35 PartitionTime: timestamppb.New(time.Unix(3600*10, 0)), 36 } 37 } 38 39 func SampleSourcesMap(commitPosition int) map[string]*pb.Sources { 40 return map[string]*pb.Sources{ 41 "sources_id": { 42 GitilesCommit: &pb.GitilesCommit{ 43 Host: "host", 44 Project: "proj", 45 Ref: "ref", 46 Position: int64(commitPosition), 47 }, 48 }, 49 } 50 } 51 52 func TestConfig() *configpb.Config { 53 return &configpb.Config{ 54 TestVariantAnalysis: &configpb.TestVariantAnalysis{ 55 Enabled: true, 56 BigqueryExportEnabled: true, 57 }, 58 } 59 }