diff options
Diffstat (limited to 'utils/license_test.go')
-rw-r--r-- | utils/license_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/utils/license_test.go b/utils/license_test.go index 6508172d5..5c0122bc0 100644 --- a/utils/license_test.go +++ b/utils/license_test.go @@ -66,3 +66,31 @@ func TestClientLicenseEtag(t *testing.T) { t.Fatal("etags should not match") } } + +func TestGetLicenseFileLocation(t *testing.T) { + fileName := GetLicenseFileLocation("") + if len(fileName) == 0 { + t.Fatal("invalid default file name") + } + + fileName = GetLicenseFileLocation("mattermost.mattermost-license") + if fileName != "mattermost.mattermost-license" { + t.Fatal("invalid file name") + } +} + +func TestGetLicenseFileFromDisk(t *testing.T) { + fileBytes := GetLicenseFileFromDisk("thisfileshouldnotexist.mattermost-license") + if len(fileBytes) > 0 { + t.Fatal("invalid bytes") + } + + fileBytes = GetLicenseFileFromDisk(FindConfigFile("config.json")) + if len(fileBytes) == 0 { // a valid bytes but should be a fail license + t.Fatal("invalid bytes") + } + + if success, _ := ValidateLicense(fileBytes); success { + t.Fatal("should have been an invalid file") + } +} |