media/test: refactor

v3.3
Nikita 3 months ago committed by demget
parent 260a67b811
commit b67df6444e

@ -6,38 +6,39 @@ import (
) )
func TestAlbumSetCaption(t *testing.T) { func TestAlbumSetCaption(t *testing.T) {
var a Album tests := []struct {
a = append(a, &Photo{Caption: "wrong_caption"}) name string
a = append(a, &Photo{Caption: "t"}) media Inputtable
a.SetCaption("correct_caption") }{
assert.Equal(t, "correct_caption", a[0].InputMedia().Caption) {
assert.Equal(t, "t", a[1].InputMedia().Caption) name: "photo",
media: &Photo{Caption: "wrong_caption"},
a = Album{} },
a = append(a, &Animation{Caption: "wrong_caption"}) {
a = append(a, &Photo{Caption: "t"}) name: "animation",
a.SetCaption("correct_caption") media: &Animation{Caption: "wrong_caption"},
assert.Equal(t, "correct_caption", a[0].InputMedia().Caption) },
assert.Equal(t, "t", a[1].InputMedia().Caption) {
name: "video",
a = Album{} media: &Video{Caption: "wrong_caption"},
a = append(a, &Audio{Caption: "wrong_caption"}) },
a = append(a, &Photo{Caption: "t"}) {
a.SetCaption("correct_caption") name: "audio",
assert.Equal(t, "correct_caption", a[0].InputMedia().Caption) media: &Audio{Caption: "wrong_caption"},
assert.Equal(t, "t", a[1].InputMedia().Caption) },
{
a = Album{} name: "document",
a = append(a, &Document{Caption: "wrong_caption"}) media: &Document{Caption: "wrong_caption"},
a = append(a, &Photo{Caption: "t"}) },
a.SetCaption("correct_caption") }
assert.Equal(t, "correct_caption", a[0].InputMedia().Caption) for _, tt := range tests {
assert.Equal(t, "t", a[1].InputMedia().Caption) t.Run(tt.name, func(t *testing.T) {
var a Album
a = Album{} a = append(a, tt.media)
a = append(a, &Video{Caption: "wrong_caption"}) a = append(a, &Photo{Caption: "random_caption"})
a = append(a, &Photo{Caption: "t"}) a.SetCaption("correct_caption")
a.SetCaption("correct_caption") assert.Equal(t, "correct_caption", a[0].InputMedia().Caption)
assert.Equal(t, "correct_caption", a[0].InputMedia().Caption) assert.Equal(t, "random_caption", a[1].InputMedia().Caption)
assert.Equal(t, "t", a[1].InputMedia().Caption) })
}
} }

Loading…
Cancel
Save