-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathget_installer_info_test.go
More file actions
57 lines (49 loc) · 1.4 KB
/
Copy pathget_installer_info_test.go
File metadata and controls
57 lines (49 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package hush
import (
"os"
"path/filepath"
"testing"
"github.com/itchio/headway/state"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGetInstallerInfo_CaseInsensitiveExtension(t *testing.T) {
consumer := &state.Consumer{}
tests := []struct {
filename string
expectedType InstallerType
}{
// Lowercase
{"test.mp3", InstallerTypeNaked},
{"test.pdf", InstallerTypeNaked},
{"test.exe", InstallerTypeNaked},
// Uppercase
{"test.MP3", InstallerTypeNaked},
{"test.PDF", InstallerTypeNaked},
{"test.EXE", InstallerTypeNaked},
// Mixed case
{"test.Mp3", InstallerTypeNaked},
{"test.Pdf", InstallerTypeNaked},
{"test.ExE", InstallerTypeNaked},
// AppImage (Linux portable apps)
{"test.appimage", InstallerTypeNaked},
{"test.AppImage", InstallerTypeNaked},
// Unknown extensions should remain unknown regardless of case
{"test.unknown", InstallerTypeUnknown},
{"test.UNKNOWN", InstallerTypeUnknown},
}
for _, tt := range tests {
t.Run(tt.filename, func(t *testing.T) {
dir := t.TempDir()
filePath := filepath.Join(dir, tt.filename)
err := os.WriteFile(filePath, []byte("test content"), 0644)
require.NoError(t, err)
file, err := os.Open(filePath)
require.NoError(t, err)
defer file.Close()
info, err := GetInstallerInfo(consumer, file)
require.NoError(t, err)
assert.Equal(t, tt.expectedType, info.Type)
})
}
}