Eliminate utils.SetLicense calls (#8217)

* eliminate utils.SetLicense calls

* test fix

* another test fix

* more test fixes
This commit is contained in:
Chris
2018-02-07 16:20:51 -06:00
committed by GitHub
parent eff65aa05c
commit 0f703a3368
14 changed files with 91 additions and 665 deletions

View File

@@ -173,6 +173,25 @@ func (l *License) ToJson() string {
return string(b)
}
// NewTestLicense returns a license that expires in the future and has the given features.
func NewTestLicense(features ...string) *License {
ret := &License{
ExpiresAt: GetMillis() + 90*24*60*60*1000,
Customer: &Customer{},
Features: &Features{},
}
ret.Features.SetDefaults()
featureMap := map[string]bool{}
for _, feature := range features {
featureMap[feature] = true
}
featureJson, _ := json.Marshal(featureMap)
json.Unmarshal(featureJson, &ret.Features)
return ret
}
func LicenseFromJson(data io.Reader) *License {
var o *License
json.NewDecoder(data).Decode(&o)