@@ -15,20 +15,30 @@ func withArchiveFetcher(t *testing.T, callback func(a *ArchiveFetcher)) {
1515}
1616
1717func TestArchiveFetcherLinks (t * testing.T ) {
18- makeTestLink := func (href string , typ string , entryLength uint64 , isCompressed bool ) manifest.Link {
19- return manifest.Link {
18+ makeTestLink := func (href string , typ string , entryLength uint64 , isCompressed bool ) struct {
19+ manifest.Link
20+ manifest.Properties
21+ } {
22+ l := manifest.Link {
2023 Href : href ,
2124 Type : typ ,
22- Properties : manifest. Properties {
23- "https://readium.org/webpub-manifest/properties#archive" : manifest.Properties {
24- "entryLength " : entryLength ,
25- "isEntryCompressed " : isCompressed ,
26- } ,
25+ }
26+ p := manifest.Properties {
27+ "https://readium.org/webpub-manifest/properties#archive " : map [ string ] interface {}{
28+ "entryLength " : entryLength ,
29+ "isEntryCompressed" : isCompressed ,
2730 },
2831 }
32+ return struct {
33+ manifest.Link
34+ manifest.Properties
35+ }{l , p }
2936 }
3037
31- mustContain := manifest.LinkList {
38+ mustContain := []struct {
39+ manifest.Link
40+ manifest.Properties
41+ }{
3242 makeTestLink ("/mimetype" , "" , 20 , false ),
3343 makeTestLink ("/EPUB/cover.xhtml" , "application/xhtml+xml" , 259 , true ),
3444 makeTestLink ("/EPUB/css/epub.css" , "text/css" , 595 , true ),
@@ -45,7 +55,12 @@ func TestArchiveFetcherLinks(t *testing.T) {
4555 links , err := a .Links ()
4656 assert .Nil (t , err )
4757
48- assert .ElementsMatch (t , mustContain , links )
58+ mustLinks := make ([]manifest.Link , len (mustContain ))
59+ for i , l := range mustContain {
60+ assert .Equal (t , l .Properties , a .Get (l .Link ).Properties ())
61+ mustLinks [i ] = l .Link
62+ }
63+ assert .ElementsMatch (t , mustLinks , links )
4964 })
5065}
5166
@@ -128,25 +143,10 @@ func TestArchiveFetcherAddsProperties(t *testing.T) {
128143 withArchiveFetcher (t , func (a * ArchiveFetcher ) {
129144 resource := a .Get (manifest.Link {Href : "/EPUB/css/epub.css" })
130145 assert .Equal (t , manifest.Properties {
131- "https://readium.org/webpub-manifest/properties#archive" : manifest.Properties {
132- "entryLength" : uint64 (595 ),
133- "isEntryCompressed" : true ,
134- },
135- }, resource .Link ().Properties )
136- })
137- }
138-
139- func TestArchiveFetcherOriginalPropertiesKept (t * testing.T ) {
140- withArchiveFetcher (t , func (a * ArchiveFetcher ) {
141- resource := a .Get (manifest.Link {Href : "/EPUB/css/epub.css" , Properties : manifest.Properties {
142- "other" : "property" ,
143- }})
144- assert .Equal (t , manifest.Properties {
145- "other" : "property" ,
146- "https://readium.org/webpub-manifest/properties#archive" : manifest.Properties {
146+ "https://readium.org/webpub-manifest/properties#archive" : map [string ]interface {}{
147147 "entryLength" : uint64 (595 ),
148148 "isEntryCompressed" : true ,
149149 },
150- }, resource .Link (). Properties )
150+ }, resource .Properties () )
151151 })
152152}
0 commit comments