1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package telegram
- import (
- "testing"
- "github.com/stretchr/testify/require"
- )
- func TestGetMimeType(t *testing.T) {
- tests := []struct {
- mimeType string
- fileName string
- expected string
- }{
- {
- fileName: "file.jpg",
- mimeType: "image/jpeg",
- expected: "image/jpeg",
- },
- {
- fileName: "file.png",
- mimeType: "image/png",
- expected: "image/png",
- },
- {
- fileName: "file.pdf",
- mimeType: "application/pdf",
- expected: "application/pdf",
- },
- {
- fileName: "file.php",
- mimeType: "application/x-php",
- expected: "application/x-php",
- },
- {
- fileName: "file.xlsx",
- mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
- expected: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
- },
- {
- fileName: "file.oga",
- mimeType: "audio/ogg",
- expected: "audio/ogg",
- },
- {
- fileName: "file.jpg",
- expected: "image/jpeg",
- },
- {
- fileName: "file.png",
- expected: "image/png",
- },
- {
- fileName: "file.mp4",
- expected: "video/mp4",
- },
- {
- fileName: "file.pdf",
- expected: "application/octet-stream",
- },
- {
- fileName: "file.oga",
- expected: "audio/ogg",
- },
- {
- fileName: "file.xlsx",
- expected: "application/octet-stream",
- },
- {
- fileName: "file.txt",
- expected: "application/octet-stream",
- },
- }
- for _, test := range tests {
- attachment := Attachment{
- FileName: test.fileName,
- MimeType: test.mimeType,
- }
- require.Equal(t, test.expected, attachment.GetMimeType())
- }
- }
|