fix: use "contents" field and remove "fullText" license field (#3857)

---------
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
Christopher Angelo Phillips
2025-05-05 21:40:09 +00:00
committed by GitHub
parent 6db60c5975
commit 1ba1186410
15 changed files with 64 additions and 40 deletions
+26
View File
@@ -1,6 +1,7 @@
package pkg
import (
"os"
"testing"
"github.com/google/go-cmp/cmp"
@@ -125,6 +126,23 @@ func TestLicenseSet_Add(t *testing.T) {
},
},
},
{
name: "licenses that are unknown with different contents can exist in the same set",
licenses: []License{
NewLicense(readFileAsString("../../internal/licenses/test-fixtures/nvidia-software-and-cuda-supplement")),
NewLicense(readFileAsString("../../internal/licenses/test-fixtures/apache-license-2.0")),
},
want: []License{
{
Contents: readFileAsString("../../internal/licenses/test-fixtures/apache-license-2.0"),
Type: license.Declared,
},
{
Contents: readFileAsString("../../internal/licenses/test-fixtures/nvidia-software-and-cuda-supplement"),
Type: license.Declared,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -160,3 +178,11 @@ func defaultLicenseComparer(x, y License) bool {
},
))
}
func readFileAsString(filepath string) string {
data, err := os.ReadFile(filepath)
if err != nil {
panic(err)
}
return string(data)
}