PLT-6090 adding ability to read license file from disk (#5895)

* PLT-6090 adding ability to read license file from disk

* Fixing unit test that fails only sometimes

* Fixing test that fails randomly
Этот коммит содержится в:
Corey Hulen
2017-03-31 06:54:30 -07:00
коммит произвёл Christopher Speller
родитель fa40bfb9e6
Коммит 00bb479989
7 изменённых файлов: 97 добавлений и 11 удалений

Просмотреть файл

@@ -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")
}
}