go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/analysis/internal/bugs/monorail/testconfig.go (about)

     1  // Copyright 2022 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 monorail
    16  
    17  import (
    18  	mpb "go.chromium.org/luci/analysis/internal/bugs/monorail/api_proto"
    19  	configpb "go.chromium.org/luci/analysis/proto/config"
    20  )
    21  
    22  // ChromiumTestPriorityField is the resource name of the priority field
    23  // that is consistent with ChromiumTestConfig.
    24  const ChromiumTestPriorityField = "projects/chromium/fieldDefs/11"
    25  
    26  // ChromiumTestTypeField is the resource name of the type field
    27  // that is consistent with ChromiumTestConfig.
    28  const ChromiumTestTypeField = "projects/chromium/fieldDefs/10"
    29  
    30  // ChromiumTestConfig provides chromium-like configuration for tests
    31  // to use.
    32  func ChromiumTestConfig() *configpb.MonorailProject {
    33  	projectCfg := &configpb.MonorailProject{
    34  		Project: "chromium",
    35  		DefaultFieldValues: []*configpb.MonorailFieldValue{
    36  			{
    37  				FieldId: 10,
    38  				Value:   "Bug",
    39  			},
    40  		},
    41  		PriorityFieldId:  11,
    42  		DisplayPrefix:    "crbug.com",
    43  		MonorailHostname: "bugs.chromium.org",
    44  	}
    45  	return projectCfg
    46  }
    47  
    48  // ChromiumTestIssuePriority returns the priority of an issue, assuming
    49  // it has been created consistent with ChromiumTestConfig.
    50  func ChromiumTestIssuePriority(issue *mpb.Issue) string {
    51  	for _, fv := range issue.FieldValues {
    52  		if fv.Field == ChromiumTestPriorityField {
    53  			return fv.Value
    54  		}
    55  	}
    56  	return ""
    57  }