@@ -15,6 +15,7 @@ package media
15
15
16
16
import (
17
17
"encoding/json"
18
+ "sort"
18
19
"testing"
19
20
20
21
qt "github.com/frankban/quicktest"
@@ -98,11 +99,28 @@ func TestBySuffix(t *testing.T) {
98
99
99
100
func TestGetFirstBySuffix (t * testing.T ) {
100
101
c := qt .New (t )
101
- _ , f , found := DefaultTypes .GetFirstBySuffix ("xml" )
102
- c .Assert (found , qt .Equals , true )
103
- c .Assert (f , qt .Equals , SuffixInfo {
104
- Suffix : "xml" ,
105
- FullSuffix : ".xml" })
102
+
103
+ types := DefaultTypes
104
+
105
+ // Issue #8406
106
+ geoJSON := newMediaTypeWithMimeSuffix ("application" , "geo" , "json" , []string {"geojson" , "gjson" })
107
+ types = append (types , geoJSON )
108
+ sort .Sort (types )
109
+
110
+ check := func (suffix string , expectedType Type ) {
111
+ t , f , found := types .GetFirstBySuffix (suffix )
112
+ c .Assert (found , qt .Equals , true )
113
+ c .Assert (f , qt .Equals , SuffixInfo {
114
+ Suffix : suffix ,
115
+ FullSuffix : "." + suffix })
116
+ c .Assert (t , qt .Equals , expectedType )
117
+ }
118
+
119
+ check ("js" , JavascriptType )
120
+ check ("json" , JSONType )
121
+ check ("geojson" , geoJSON )
122
+ check ("gjson" , geoJSON )
123
+
106
124
}
107
125
108
126
func TestFromTypeString (t * testing.T ) {
0 commit comments