Skip to content

Commit

Permalink
Store package in response instead of the path
Browse files Browse the repository at this point in the history
With the package in the response we can update it more easily depending on the
result data.
  • Loading branch information
rafaeljusto committed Oct 29, 2015
1 parent 1359dca commit be1b62b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions cmd/gddoexp/gddoexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ func main() {
if response.Error != nil {
log.Println(response.Error)
} else if response.Suppress {
log.Printf("package “%s” should be suppressed\n", response.Path)
log.Printf("package “%s” should be suppressed\n", response.Package.Path)
if progress != nil && !*progress {
fmt.Println(response.Path)
fmt.Println(response.Package.Path)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions gddoexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type gddoDB interface {
// SuppressResponse stores the information of a path verification on an
// asynchronous check.
type SuppressResponse struct {
Path string
Package database.Package
Suppress bool
Cache bool
Error error
Expand Down Expand Up @@ -97,7 +97,7 @@ func ShouldSuppressPackages(packages []database.Package, db gddoDB, auth *Github
for p := range in {
suppress, cache, err := ShouldSuppressPackage(p, db, auth)
out <- SuppressResponse{
Path: p.Path,
Package: p,
Suppress: suppress,
Cache: cache,
Error: err,
Expand Down
32 changes: 16 additions & 16 deletions gddoexp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,23 +448,23 @@ func TestShouldSuppressPackages(t *testing.T) {
},
expected: []gddoexp.SuppressResponse{
{
Path: "github.com/docker/docker",
Package: database.Package{Path: "github.com/docker/docker"},
Suppress: true,
},
{
Path: "github.com/golang/gddo",
Package: database.Package{Path: "github.com/golang/gddo"},
Suppress: true,
},
{
Path: "github.com/golang/go",
Package: database.Package{Path: "github.com/golang/go"},
Suppress: true,
},
{
Path: "github.com/miekg/dns",
Package: database.Package{Path: "github.com/miekg/dns"},
Suppress: true,
},
{
Path: "github.com/rafaeljusto/gddoexp",
Package: database.Package{Path: "github.com/rafaeljusto/gddoexp"},
Suppress: true,
},
},
Expand Down Expand Up @@ -509,23 +509,23 @@ func TestShouldSuppressPackages(t *testing.T) {
},
expected: []gddoexp.SuppressResponse{
{
Path: "github.com/docker/docker",
Package: database.Package{Path: "github.com/docker/docker"},
Suppress: true,
},
{
Path: "github.com/golang/gddo",
Package: database.Package{Path: "github.com/golang/gddo"},
Suppress: true,
},
{
Path: "github.com/golang/go",
Package: database.Package{Path: "github.com/golang/go"},
Suppress: true,
},
{
Path: "github.com/miekg/dns",
Package: database.Package{Path: "github.com/miekg/dns"},
Suppress: true,
},
{
Path: "github.com/rafaeljusto/gddoexp",
Package: database.Package{Path: "github.com/rafaeljusto/gddoexp"},
Suppress: true,
},
},
Expand Down Expand Up @@ -563,27 +563,27 @@ func TestShouldSuppressPackages(t *testing.T) {
},
expected: []gddoexp.SuppressResponse{
{
Path: "github.com/docker/docker",
Package: database.Package{Path: "github.com/docker/docker"},
Suppress: true,
Cache: true,
},
{
Path: "github.com/golang/gddo",
Package: database.Package{Path: "github.com/golang/gddo"},
Suppress: true,
Cache: true,
},
{
Path: "github.com/golang/go",
Package: database.Package{Path: "github.com/golang/go"},
Suppress: true,
Cache: true,
},
{
Path: "github.com/miekg/dns",
Package: database.Package{Path: "github.com/miekg/dns"},
Suppress: true,
Cache: true,
},
{
Path: "github.com/rafaeljusto/gddoexp",
Package: database.Package{Path: "github.com/rafaeljusto/gddoexp"},
Suppress: true,
Cache: true,
},
Expand Down Expand Up @@ -1229,7 +1229,7 @@ type bySuppressResponsePath []gddoexp.SuppressResponse

func (b bySuppressResponsePath) Len() int { return len(b) }
func (b bySuppressResponsePath) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
func (b bySuppressResponsePath) Less(i, j int) bool { return b[i].Path < b[j].Path }
func (b bySuppressResponsePath) Less(i, j int) bool { return b[i].Package.Path < b[j].Package.Path }

type byFastForkResponsePath []gddoexp.FastForkResponse

Expand Down

0 comments on commit be1b62b

Please sign in to comment.