storj/storagenode/payout/service_test.go
Qweder93 8182fdad0b storagenode: heldamount renamed to payouts, renamed some methods and structs to more meaningful names. grouped estimated payout with pathouts
satellite: heldamount renamed to SNOpayouts.

Change-Id: I244b4d2454e0621f4b8e22d3c0d3e602c0bbcb02
2020-09-16 14:57:35 +00:00

44 lines
1.0 KiB
Go

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package payout
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestParsePeriodRange(t *testing.T) {
testCases := [...]struct {
periodStart string
periodEnd string
periods []string
}{
{"2020-01", "2020-02", []string{"2020-01", "2020-02"}},
{"2020-01", "2020-01", []string{"2020-01"}},
{"2019-11", "2020-02", []string{"2019-11", "2019-12", "2020-01", "2020-02"}},
{"", "2020-02", nil},
{"2020-01", "", nil},
{"2020-01-01", "2020-02", nil},
{"2020-44", "2020-02", nil},
{"2020-01", "2020-44", nil},
{"2020-01", "2019-01", nil},
{"2020-02", "2020-01", nil},
}
for _, tc := range testCases {
periods, err := parsePeriodRange(tc.periodStart, tc.periodEnd)
require.Equal(t, len(periods), len(tc.periods))
if periods != nil {
for i := 0; i < len(periods); i++ {
require.Equal(t, periods[i], tc.periods[i])
require.NoError(t, err)
}
} else {
require.Error(t, err)
}
}
}