gopkg.in/tools/godep.v38@v38.0.0-20151216225452-4154dbb67855/license_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 ) 6 7 // most of these were found via google searches 8 // site:github.com FILENAME 9 // 10 func TestLicenseFiles(t *testing.T) { 11 var testcases = []struct { 12 filename string 13 license bool 14 legal bool 15 }{ 16 {"license", true, true}, 17 {"License", true, true}, 18 {"LICENSE.md", true, true}, 19 {"LICENSE.rst", true, true}, 20 {"LICENSE.txt", true, true}, 21 {"copying", true, true}, 22 {"COPYING.txt", true, true}, 23 {"unlicense", true, true}, 24 {"copyright", true, true}, 25 {"COPYRIGHT.txt", true, true}, 26 {"copyleft", true, true}, 27 {"COPYLEFT.txt", true, true}, 28 {"copyleft.txt", true, true}, 29 {"Copyleft.txt", true, true}, 30 {"copyleft-next-0.2.1.txt", true, true}, 31 {"legal", false, true}, 32 {"notice", false, true}, 33 {"NOTICE", false, true}, 34 {"disclaimer", false, true}, 35 {"patent", false, true}, 36 {"patents", false, true}, 37 {"third-party", false, true}, 38 {"thirdparty", false, true}, 39 {"thirdparty.txt", false, true}, 40 {"license-ThirdParty.txt", true, true}, 41 {"LICENSE-ThirdParty.txt", true, true}, 42 {"THIRDPARTY.md", false, true}, 43 {"third-party.md", false, true}, 44 {"THIRD-PARTY.txt", false, true}, 45 {"extensions-third-party.md", false, true}, 46 {"ThirdParty.md", false, true}, 47 {"third-party-licenses.md", false, true}, 48 {"0070-01-01-third-party.md", false, true}, 49 {"LEGAL.txt", false, true}, 50 {"legal.txt", false, true}, 51 {"Legal.md", false, true}, 52 {"LEGAL.md", false, true}, 53 {"legal.rst", false, true}, 54 {"Legal.rtf", false, true}, 55 {"legal.rtf", false, true}, 56 {"PATENTS.TXT", false, true}, 57 {"ttf-PATENTS.txt", false, true}, 58 {"patents.txt", false, true}, 59 {"INRIA-DISCLAIMER.txt", false, true}, 60 61 {"MPL-2.0-no-copyleft-exception.txt", false, false}, 62 } 63 64 for pos, tt := range testcases { 65 license := IsLicenseFile(tt.filename) 66 if tt.license != license { 67 if license { 68 t.Errorf("%d/file %q is not marked as license", pos, tt.filename) 69 } else { 70 t.Errorf("%d/file %q was marked incorrectly as a license", pos, tt.filename) 71 } 72 } 73 74 legal := IsLegalFile(tt.filename) 75 if tt.legal != legal { 76 if legal { 77 t.Errorf("%d/File %q is not marked as legal file", pos, tt.filename) 78 } else { 79 t.Errorf("%d/File %q was marked incorrectly as a legal file", pos, tt.filename) 80 } 81 } 82 } 83 }