github.com/vnforks/kid@v5.11.1+incompatible/model/slack_attachment_test.go (about) 1 package model 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestParseSlackAttachment(t *testing.T) { 10 t.Run("empty list", func(t *testing.T) { 11 post := &Post{} 12 attachments := []*SlackAttachment{} 13 14 ParseSlackAttachment(post, attachments) 15 16 expectedPost := &Post{ 17 Type: POST_SLACK_ATTACHMENT, 18 Props: map[string]interface{}{ 19 "attachments": []*SlackAttachment{}, 20 }, 21 } 22 assert.Equal(t, expectedPost, post) 23 }) 24 25 t.Run("list with nil", func(t *testing.T) { 26 post := &Post{} 27 attachments := []*SlackAttachment{ 28 nil, 29 } 30 31 ParseSlackAttachment(post, attachments) 32 33 expectedPost := &Post{ 34 Type: POST_SLACK_ATTACHMENT, 35 Props: map[string]interface{}{ 36 "attachments": []*SlackAttachment{}, 37 }, 38 } 39 assert.Equal(t, expectedPost, post) 40 }) 41 }