Skip to content

Commit

Permalink
Add ranker test
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed Sep 4, 2019
1 parent 36c7397 commit f70dc06
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions processor/ranker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,30 @@ import (
)

func TestRanker(t *testing.T) {
results := []*FileJob{}

locations := map[string][]int{}
locations["test"] = []int{1,2,3}

results := []*FileJob{
{
Filename: "test.go",
Extension: "go",
Location: "/",
Content: []byte("content"),
Bytes: 10,
Hash: nil,
Binary: false,
Score: 0,
Locations: locations,
},
}
ranked := RankResults(results)

if len(ranked) != 0 {
t.Error("Should be zero results")
if len(ranked) != 1 {
t.Error("Should be one results")
}

if ranked[0].Score <= 0 {
t.Error("Score should be greater than 0")
}
}

0 comments on commit f70dc06

Please sign in to comment.