25 lines
577 B
Go
25 lines
577 B
Go
package rip
|
|
|
|
import "testing"
|
|
|
|
func TestParseSearchOutput(t *testing.T) {
|
|
output := `results: 100
|
|
1. id=dpkjsfxlbkrwa | Intimate Fonk
|
|
results: 1
|
|
1. id=dpkjsfxlbkrwa | Intimate Fonk
|
|
`
|
|
hits := parseSearchOutput(output)
|
|
if len(hits) != 1 {
|
|
t.Fatalf("expected 1 deduped hit, got %d", len(hits))
|
|
}
|
|
if hits[0].ID != "dpkjsfxlbkrwa" || hits[0].Title != "Intimate Fonk" {
|
|
t.Fatalf("unexpected hit: %+v", hits[0])
|
|
}
|
|
}
|
|
|
|
func TestParseNoResults(t *testing.T) {
|
|
if hits := parseSearchOutput("no results\n"); len(hits) != 0 {
|
|
t.Fatalf("expected no hits, got %+v", hits)
|
|
}
|
|
}
|