renamed *periodic to *incremental

This commit is contained in:
Radu Ioan Fericean
2016-04-25 22:26:20 +03:00
parent 768cdcc43a
commit 30f42c07f2
2 changed files with 6 additions and 6 deletions

View File

@@ -30,14 +30,14 @@ func ParseBalanceFilterValue(val string) (*ValueFormula, error) {
type valueFormula func(map[string]interface{}) float64
const (
PERIODIC = "*periodic"
INCREMENTAL = "*incremental"
)
var ValueFormulas = map[string]valueFormula{
PERIODIC: periodicFormula,
INCREMENTAL: incrementalFormula,
}
func periodicFormula(params map[string]interface{}) float64 {
func incrementalFormula(params map[string]interface{}) float64 {
// check parameters
unitsInterface, unitsFound := params["Units"]
intervalInterface, intervalFound := params["Interval"]

View File

@@ -11,7 +11,7 @@ func TestValueFormulaDayWeek(t *testing.T) {
if err := json.Unmarshal([]byte(`{"Units":10, "Interval":"week", "Increment":"day"}`), &params); err != nil {
t.Error("error unmarshalling params: ", err)
}
if x := periodicFormula(params); x != 10/7.0 {
if x := incrementalFormula(params); x != 10/7.0 {
t.Error("error caclulating value using formula: ", x)
}
}
@@ -22,7 +22,7 @@ func TestValueFormulaDayMonth(t *testing.T) {
t.Error("error unmarshalling params: ", err)
}
now := time.Now()
if x := periodicFormula(params); x != 10/DaysInMonth(now.Year(), now.Month()) {
if x := incrementalFormula(params); x != 10/DaysInMonth(now.Year(), now.Month()) {
t.Error("error caclulating value using formula: ", x)
}
}
@@ -33,7 +33,7 @@ func TestValueFormulaDayYear(t *testing.T) {
t.Error("error unmarshalling params: ", err)
}
now := time.Now()
if x := periodicFormula(params); x != 10/DaysInYear(now.Year()) {
if x := incrementalFormula(params); x != 10/DaysInYear(now.Year()) {
t.Error("error caclulating value using formula: ", x)
}
}