@@ -13,6 +13,7 @@ import (
1313 "code.gitea.io/gitea/modules/json"
1414
1515 "github.com/stretchr/testify/assert"
16+ "github.com/stretchr/testify/require"
1617)
1718
1819func TestParsePackage (t * testing.T ) {
@@ -291,11 +292,36 @@ func TestParsePackage(t *testing.T) {
291292 assert .Equal (t , packageDescription , p .Metadata .Readme )
292293 assert .Equal (t , packageAuthor , p .Metadata .Author )
293294 assert .Equal (t , packageBin , p .Metadata .Bin ["bin" ])
294- assert .Equal (t , "MIT" , p .Metadata .License )
295+ assert .Equal (t , "MIT" , string ( p .Metadata .License ) )
295296 assert .Equal (t , "https://gitea.io/" , p .Metadata .ProjectURL )
296297 assert .Contains (t , p .Metadata .Dependencies , "package" )
297298 assert .Equal (t , "1.2.0" , p .Metadata .Dependencies ["package" ])
298299 assert .Equal (t , repository .Type , p .Metadata .Repository .Type )
299300 assert .Equal (t , repository .URL , p .Metadata .Repository .URL )
300301 })
302+
303+ t .Run ("ValidLicenseMap" , func (t * testing.T ) {
304+ packageJSON := `{
305+ "versions": {
306+ "0.1.1": {
307+ "name": "dev-null",
308+ "version": "0.1.1",
309+ "license": {
310+ "type": "MIT"
311+ },
312+ "dist": {
313+ "integrity": "sha256-"
314+ }
315+ }
316+ },
317+ "_attachments": {
318+ "foo": {
319+ "data": "AAAA"
320+ }
321+ }
322+ }`
323+ p , err := ParsePackage (strings .NewReader (packageJSON ))
324+ require .NoError (t , err )
325+ require .Equal (t , "MIT" , string (p .Metadata .License ))
326+ })
301327}
0 commit comments