Merge "add error handling to cquery in MockBazelContext"

This commit is contained in:
Sam Delmerico 2023-01-25 17:08:12 +00:00 committed by Gerrit Code Review
commit 9202bb01de

View file

@ -233,27 +233,42 @@ func (m MockBazelContext) QueueBazelRequest(_ string, _ cqueryRequest, _ configK
}
func (m MockBazelContext) GetOutputFiles(label string, _ configKey) ([]string, error) {
result, _ := m.LabelToOutputFiles[label]
result, ok := m.LabelToOutputFiles[label]
if !ok {
return []string{}, fmt.Errorf("no target with label %q in LabelToOutputFiles", label)
}
return result, nil
}
func (m MockBazelContext) GetCcInfo(label string, _ configKey) (cquery.CcInfo, error) {
result, _ := m.LabelToCcInfo[label]
result, ok := m.LabelToCcInfo[label]
if !ok {
return cquery.CcInfo{}, fmt.Errorf("no target with label %q in LabelToCcInfo", label)
}
return result, nil
}
func (m MockBazelContext) GetPythonBinary(label string, _ configKey) (string, error) {
result, _ := m.LabelToPythonBinary[label]
result, ok := m.LabelToPythonBinary[label]
if !ok {
return "", fmt.Errorf("no target with label %q in LabelToPythonBinary", label)
}
return result, nil
}
func (m MockBazelContext) GetApexInfo(label string, _ configKey) (cquery.ApexInfo, error) {
result, _ := m.LabelToApexInfo[label]
result, ok := m.LabelToApexInfo[label]
if !ok {
return cquery.ApexInfo{}, fmt.Errorf("no target with label %q in LabelToApexInfo", label)
}
return result, nil
}
func (m MockBazelContext) GetCcUnstrippedInfo(label string, _ configKey) (cquery.CcUnstrippedInfo, error) {
result, _ := m.LabelToCcBinary[label]
result, ok := m.LabelToCcBinary[label]
if !ok {
return cquery.CcUnstrippedInfo{}, fmt.Errorf("no target with label %q in LabelToCcBinary", label)
}
return result, nil
}