model function unit tests!
This commit is contained in:
parent
e5ae167550
commit
6db35b2f99
9 changed files with 254 additions and 16 deletions
43
model/track_test.go
Normal file
43
model/track_test.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_Track_DescriptionHTML(t *testing.T) {
|
||||
track := Track{
|
||||
Description: "this is\na test\n<strong>description!</strong>",
|
||||
}
|
||||
|
||||
// descriptions are set by privileged users,
|
||||
// so we'll allow HTML injection here
|
||||
want := "this is<br>a test<br><strong>description!</strong>"
|
||||
got := track.GetDescriptionHTML()
|
||||
if want != string(got) {
|
||||
t.Errorf(`track description incorrectly formatted (want "%s", got "%s")`, want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Track_LyricsHTML(t *testing.T) {
|
||||
track := Track{
|
||||
Lyrics: "these are\ntest\n<strong>lyrics!</strong>",
|
||||
}
|
||||
|
||||
// lyrics are set by privileged users,
|
||||
// so we'll allow HTML injection here
|
||||
want := "these are<br>test<br><strong>lyrics!</strong>"
|
||||
got := track.GetLyricsHTML()
|
||||
if want != string(got) {
|
||||
t.Errorf(`track lyrics incorrectly formatted (want "%s", got "%s")`, want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Track_Add(t *testing.T) {
|
||||
track := Track{}
|
||||
|
||||
want := 4
|
||||
got := track.Add(2, 2)
|
||||
if want != got {
|
||||
t.Errorf(`somehow, we screwed up addition. (want %d, got %d)`, want, got)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue