fixes bug that doesnt output quote if less than 2 quotes for that time
Some checks reported errors
continuous-integration/drone/tag Build was killed

This commit is contained in:
Marvin Steadfast 2020-01-07 14:23:16 +01:00
parent 7733b81a31
commit f3fecbbdc2
2 changed files with 22 additions and 0 deletions

View File

@ -30,6 +30,8 @@ func get(qs map[string][]Quote, t string) Quote {
if len(qs[t]) != 1 {
rand.Seed(time.Now().Unix())
quote = qs[t][rand.Intn(len(qs[t]))]
} else {
quote = qs[t][0]
}
}

View File

@ -26,3 +26,23 @@ func TestDecorate(t *testing.T) {
}
}
}
func TestGet(t *testing.T) {
tables := []struct {
m map[string][]Quote
q Quote
}{
{
map[string][]Quote{"00:00": {
Quote{"Max Mustermann", "Testbook", "This is a time!", "time"},
}},
Quote{"Max Mustermann", "Testbook", "This is a time!", "time"},
},
}
for _, table := range tables {
q := get(table.m, "00:00")
if q != table.q {
t.Errorf("quote \"%+v\" is not like \"%+v\"", q, table.q)
}
}
}