Unverified Commit a78d1540 authored by Alexander Lukyanchikov's avatar Alexander Lukyanchikov Committed by GitHub
Browse files

Merge pull request #26 from sqshq/first_run_license_validation

Issue with first run license validation
Showing with 41 additions and 1 deletion
+41 -1
......@@ -9,7 +9,7 @@ require (
github.com/lunixbochs/vtclean v1.0.0
github.com/mattn/go-runewidth v0.0.4
github.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22
)
......@@ -42,6 +42,8 @@ func GetLicense() *License {
func SaveLicense(license License) {
initStorage()
file, err := yaml.Marshal(license)
if err != nil {
log.Fatalf("Failed to marshal license file: %v", err)
......
package metadata
import (
"os"
"testing"
)
func Test_getEmptyLicense(t *testing.T) {
cleanupPlatformStorage()
license := GetLicense()
if license != nil {
t.Errorf("expected to be nil")
}
}
func Test_saveAndGetExistingLicense(t *testing.T) {
cleanupPlatformStorage()
original := License{
Valid: true,
}
SaveLicense(original)
retrieved := *GetLicense()
if original != retrieved {
t.Errorf("read file != saved file")
}
}
func cleanupPlatformStorage() {
_ = os.RemoveAll(getPlatformStoragePath(""))
_ = os.Remove(getPlatformStoragePath(""))
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment