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
Some checks reported errors
continuous-integration/drone/tag Build was killed
This commit is contained in:
parent
7733b81a31
commit
f3fecbbdc2
2
main.go
2
main.go
@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
|
20
main_test.go
20
main_test.go
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user