From f70dc06058162efeead08e5aadfbbfab0fb8a795 Mon Sep 17 00:00:00 2001 From: Ben Boyter Date: Wed, 4 Sep 2019 10:23:21 +1000 Subject: [PATCH] Add ranker test --- processor/ranker_test.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/processor/ranker_test.go b/processor/ranker_test.go index 1d9bdb9..258b1b0 100644 --- a/processor/ranker_test.go +++ b/processor/ranker_test.go @@ -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") } }