testing promotion actions
This commit is contained in:
@@ -380,7 +380,7 @@ func WalkConditions(conds []Condition, fn func(c Condition) bool) {
|
||||
}
|
||||
|
||||
type PromotionState struct {
|
||||
Vouchers []PromotionRule `json:"promotions"`
|
||||
Promotions []PromotionRule `json:"promotions"`
|
||||
}
|
||||
|
||||
type StateFile struct {
|
||||
@@ -389,7 +389,7 @@ type StateFile struct {
|
||||
}
|
||||
|
||||
func (sf *StateFile) GetPromotion(id string) (*PromotionRule, bool) {
|
||||
for _, v := range sf.State.Vouchers {
|
||||
for _, v := range sf.State.Promotions {
|
||||
if v.ID == id {
|
||||
return &v, true
|
||||
}
|
||||
@@ -397,14 +397,14 @@ func (sf *StateFile) GetPromotion(id string) (*PromotionRule, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func LoadStateFile(fileName string) (*PromotionState, error) {
|
||||
func LoadStateFile(fileName string) (*StateFile, error) {
|
||||
f, err := os.Open(fileName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
dec := json.NewDecoder(f)
|
||||
sf := &PromotionState{}
|
||||
sf := &StateFile{}
|
||||
err = dec.Decode(sf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user