github.com/vladimirvivien/godep@v0.0.0-20160710170555-3c0ccb9a2415/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  		{"licence", true, true},
    22  		{"LICENCE.broadcom", true, true},
    23  		{"LICENCE.md", true, true},
    24  		{"copying", true, true},
    25  		{"COPYING.txt", true, true},
    26  		{"unlicense", true, true},
    27  		{"copyright", true, true},
    28  		{"COPYRIGHT.txt", true, true},
    29  		{"copyleft", true, true},
    30  		{"COPYLEFT.txt", true, true},
    31  		{"copyleft.txt", true, true},
    32  		{"Copyleft.txt", true, true},
    33  		{"copyleft-next-0.2.1.txt", true, true},
    34  		{"legal", false, true},
    35  		{"notice", false, true},
    36  		{"NOTICE", false, true},
    37  		{"disclaimer", false, true},
    38  		{"patent", false, true},
    39  		{"patents", false, true},
    40  		{"third-party", false, true},
    41  		{"thirdparty", false, true},
    42  		{"thirdparty.txt", false, true},
    43  		{"license-ThirdParty.txt", true, true},
    44  		{"LICENSE-ThirdParty.txt", true, true},
    45  		{"THIRDPARTY.md", false, true},
    46  		{"third-party.md", false, true},
    47  		{"THIRD-PARTY.txt", false, true},
    48  		{"extensions-third-party.md", false, true},
    49  		{"ThirdParty.md", false, true},
    50  		{"third-party-licenses.md", false, true},
    51  		{"0070-01-01-third-party.md", false, true},
    52  		{"LEGAL.txt", false, true},
    53  		{"legal.txt", false, true},
    54  		{"Legal.md", false, true},
    55  		{"LEGAL.md", false, true},
    56  		{"legal.rst", false, true},
    57  		{"Legal.rtf", false, true},
    58  		{"legal.rtf", false, true},
    59  		{"PATENTS.TXT", false, true},
    60  		{"ttf-PATENTS.txt", false, true},
    61  		{"patents.txt", false, true},
    62  		{"INRIA-DISCLAIMER.txt", false, true},
    63  
    64  		{"MPL-2.0-no-copyleft-exception.txt", false, false},
    65  	}
    66  
    67  	for pos, tt := range testcases {
    68  		license := IsLicenseFile(tt.filename)
    69  		if tt.license != license {
    70  			if license {
    71  				t.Errorf("%d/file %q is not marked as license", pos, tt.filename)
    72  			} else {
    73  				t.Errorf("%d/file %q was marked incorrectly as a license", pos, tt.filename)
    74  			}
    75  		}
    76  
    77  		legal := IsLegalFile(tt.filename)
    78  		if tt.legal != legal {
    79  			if legal {
    80  				t.Errorf("%d/File %q is not marked as legal file", pos, tt.filename)
    81  			} else {
    82  				t.Errorf("%d/File %q was marked incorrectly as a legal file", pos, tt.filename)
    83  			}
    84  		}
    85  	}
    86  }