Properly handle different attachment use cases

This commit is contained in:
Philipp Heckel 2022-01-08 15:47:08 -05:00
parent cefe276ce5
commit 44a9509cd6
7 changed files with 202 additions and 75 deletions

19
server/util_test.go Normal file
View file

@ -0,0 +1,19 @@
package server
import (
"github.com/stretchr/testify/require"
"testing"
)
func TestMaybePeakAttachmentURL_Success(t *testing.T) {
m := &message{
Attachment: &attachment{
URL: "https://ntfy.sh/static/img/ntfy.png",
},
}
require.Nil(t, maybePeakAttachmentURL(m))
require.Equal(t, "ntfy.png", m.Attachment.Name)
require.Equal(t, int64(3627), m.Attachment.Size)
require.Equal(t, "image/png", m.Attachment.Type)
require.Equal(t, int64(0), m.Attachment.Expires)
}