Debian Codegraph @

licensedb/licensedb_test.go

raw symbols SCIP
1 package licensedbscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/
2
3 import (
4 "osscip-go gomod github.com/golang/go/src go1.18 os/"
5 "path/filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/"
6 "testingscip-go gomod github.com/golang/go/src go1.18 testing/"
7
8 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/"
9 "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/require`/"
10
11 "github.com/go-enry/go-license-detector/v4/licensedb/filerscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb/filer`/"
12 )
13
14 func BenchmarkDetectscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/BenchmarkDetect().(b *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Bscip-go gomod github.com/golang/go/src go1.18 testing/B#) {
15 f := pwdFilerscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/pwdFiler().()
16 b.ResetTimerscip-go gomod github.com/golang/go/src go1.18 testing/B#ResetTimer().()
17 for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.18 testing/B#N.; i++ {
18 _, err := Detectscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/Detect().(f)
19 if err != nil {
20 panic(err)
21 }
22 }
23 }
24
25 func BenchmarkDetectWithPreloadscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/BenchmarkDetectWithPreload().(b *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Bscip-go gomod github.com/golang/go/src go1.18 testing/B#) {
26 f := pwdFilerscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/pwdFiler().()
27 Preloadscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/Preload().()
28 b.ResetTimerscip-go gomod github.com/golang/go/src go1.18 testing/B#ResetTimer().()
29 for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.18 testing/B#N.; i++ {
30 _, err := Detectscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/Detect().(f)
31 if err != nil {
32 panic(err)
33 }
34 }
35 }
36
37 func pwdFilerscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/pwdFiler().() filerscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb/filer`/.Filerscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb/filer`/Filer# {
38 pwd, err := osscip-go gomod github.com/golang/go/src go1.18 os/.Getwdscip-go gomod github.com/golang/go/src go1.18 os/Getwd().()
39 if err != nil {
40 panic(err)
41 }
42 root := filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Dir().(pwd)
43 f, err := filerscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb/filer`/.FromDirectoryscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb/filer`/FromDirectory().(root)
44 if err != nil {
45 panic(err)
46 }
47 return f
48 }
49
50 func TestLicenseURLsscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/TestLicenseURLs().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
51 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("existing license", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
52 res, err := LicenseURLsscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/LicenseURLs().("ODbL-1.0")
53 requirescip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/require`/NoError().(t, err)
54 assertscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/Equal().(t, []string{"http://www.opendatacommons.org/licenses/odbl/1.0/", "https://opendatacommons.org/licenses/odbl/1-0/"}, res)
55 })
56
57 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("not existing license", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
58 _, err := LicenseURLsscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/LicenseURLs().("bad-license-key")
59 requirescip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/require`/Equal().(t, ErrUnknownLicenseIDscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/ErrUnknownLicenseID., err)
60 })
61 }
62
63 func TestLicenseNamescip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/TestLicenseName().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
64 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("existing license", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
65 res, err := LicenseNamescip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/LicenseName().("ODbL-1.0")
66 requirescip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/require`/NoError().(t, err)
67 assertscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/Equal().(t, "Open Data Commons Open Database License v1.0", res)
68 })
69
70 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().("not existing license", func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
71 _, err := LicenseNamescip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/LicenseName().("bad-license-key")
72 requirescip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/require`/Equal().(t, ErrUnknownLicenseIDscip-go gomod github.com/go-enry/go-license-detector/v4 . `github.com/go-enry/go-license-detector/v4/licensedb`/ErrUnknownLicenseID., err)
73 })
74 }