package store import ( "testing" "github.com/stretchr/testify/assert" ) func TestComment_Sanitize(t *testing.T) { tbl := []struct { inp Comment out Comment }{ {inp: Comment{}, out: Comment{}}, { inp: Comment{ Text: `blah XSS` + "\n\t", User: User{ID: `username`}, }, out: Comment{ Text: `blah XSS`, User: User{ID: `<a href="http://blah.com">username</a>`}, }, }, } for n, tt := range tbl { tt.inp.Sanitize() assert.Equal(t, tt.out, tt.inp, "check #%d", n) } }