Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Make it more clear when a conversion error was unexpected or missing
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynvs committed Aug 11, 2017
1 parent 996a18f commit 8d34136
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/dep/glide_importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func TestGlideConfig_Convert(t *testing.T) {
manifest, lock, convertErr := g.convert(testCase.projectRoot)
err := validateConvertTestCase(testCase.convertTestCase, manifest, lock, convertErr)
if err != nil {
t.Fatalf("%+v", err)
t.Fatalf("%#v", err)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dep/godep_importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestGodepConfig_Convert(t *testing.T) {
manifest, lock, convertErr := g.convert(testCase.projectRoot)
err := validateConvertTestCase(testCase.convertTestCase, manifest, lock, convertErr)
if err != nil {
t.Fatalf("%+v", err)
t.Fatalf("%#v", err)
}
})
}
Expand Down
13 changes: 8 additions & 5 deletions cmd/dep/root_analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,17 @@ type convertTestCase struct {
// validateConvertTestCase returns an error if any of the importer's
// conversion validations failed.
func validateConvertTestCase(testCase *convertTestCase, manifest *dep.Manifest, lock *dep.Lock, convertErr error) error {
if convertErr != nil {
if testCase.wantConvertErr {
return nil
if testCase.wantConvertErr {
if convertErr == nil {
return errors.New("Expected the conversion to fail, but it did not return an error")
}
return nil
}

return convertErr
if convertErr != nil {
return errors.Wrap(convertErr, "Expected the conversion to pass, but it returned an error")
}

// Ignored projects checks.
if len(manifest.Ignored) != testCase.wantIgnoreCount {
return errors.Errorf("Expected manifest to have %d ignored project(s), got %d",
Expand Down

0 comments on commit 8d34136

Please sign in to comment.