-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Go mod: Handle multi-line error messages
Changes the go mod updater error handling to fall back to matching the whole string if no lines where matched against the regex. Some errors where surfacing with an empty error message as we initially match on the whole string but filter per line.
- Loading branch information
Showing
4 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -465,6 +465,39 @@ | |
end | ||
end | ||
end | ||
|
||
context "for an unknown revision version" do | ||
let(:project_name) { "unknown_revision_version" } | ||
let(:dependency_name) do | ||
"github.com/deislabs/oras" | ||
end | ||
let(:dependency_version) { "v0.10.0" } | ||
let(:dependency_previous_version) { "v0.9.0" } | ||
let(:requirements) do | ||
[{ | ||
file: "go.mod", | ||
requirement: dependency_version, | ||
groups: [], | ||
source: { | ||
type: "default", | ||
source: "github.com/deislabs/oras" | ||
} | ||
}] | ||
end | ||
let(:previous_requirements) { [] } | ||
|
||
it "raises the correct error" do | ||
error_class = Dependabot::DependencyFileNotResolvable | ||
expect { updater.updated_go_sum_content }. | ||
to raise_error(error_class) do |error| | ||
expect(error.message).to include( | ||
"go: github.com/deislabs/[email protected] requires\n"\ | ||
" github.com/docker/[email protected]: "\ | ||
"invalid version: unknown revision" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "#updated_go_sum_content" do | ||
|
7 changes: 7 additions & 0 deletions
7
go_modules/spec/fixtures/projects/unknown_revision_version/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module github.com/dependabot/vgotest | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/deislabs/oras v0.9.0 | ||
) |
8 changes: 8 additions & 0 deletions
8
go_modules/spec/fixtures/projects/unknown_revision_version/main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
import ( | ||
_ "github.com/deislabs/oras" | ||
) | ||
|
||
func main() { | ||
} |