Eliminate utils.SetLicense calls (#8217)

* eliminate utils.SetLicense calls

* test fix

* another test fix

* more test fixes
Этот коммит содержится в:
Chris
2018-02-07 16:20:51 -06:00
коммит произвёл GitHub
родитель eff65aa05c
Коммит 0f703a3368
14 изменённых файлов: 91 добавлений и 665 удалений

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

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