summaryrefslogtreecommitdiffstats
path: root/utils/license_test.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-03-31 06:54:30 -0700
committerChristopher Speller <crspeller@gmail.com>2017-03-31 09:54:30 -0400
commit00bb4799899cbbcdf48b147639dee3cee7ea199b (patch)
tree74881150207ae980b1703644da265fed6886d65d /utils/license_test.go
parentfa40bfb9e6f3bcdfe631301be2ee3ce755cbef0e (diff)
downloadchat-00bb4799899cbbcdf48b147639dee3cee7ea199b.tar.gz
chat-00bb4799899cbbcdf48b147639dee3cee7ea199b.tar.bz2
chat-00bb4799899cbbcdf48b147639dee3cee7ea199b.zip
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
Diffstat (limited to 'utils/license_test.go')
-rw-r--r--utils/license_test.go28
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")
+ }
+}