|
|
@@ -5,6 +5,7 @@ import (
|
|
|
"testing"
|
|
|
"time"
|
|
|
|
|
|
+ "github.com/opencost/opencost/core/pkg/opencost"
|
|
|
"github.com/opencost/opencost/modules/collector-source/pkg/util"
|
|
|
)
|
|
|
|
|
|
@@ -21,6 +22,8 @@ func Test_repoStoreProvider_getStoreKeys(t *testing.T) {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
+ win24h, _ := opencost.ParseWindowUTC("24h")
|
|
|
+
|
|
|
tests := map[string]struct {
|
|
|
configs []util.ResolutionConfiguration
|
|
|
start time.Time
|
|
|
@@ -28,40 +31,47 @@ func Test_repoStoreProvider_getStoreKeys(t *testing.T) {
|
|
|
intevalKey string
|
|
|
startKey time.Time
|
|
|
}{
|
|
|
- "10m": {
|
|
|
- configs: defaultResConfigs,
|
|
|
- start: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
- end: time.Date(2025, time.May, 3, 0, 10, 0, 0, time.UTC),
|
|
|
- intevalKey: "10m",
|
|
|
- startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
- },
|
|
|
- "1h": {
|
|
|
+ // "10m": {
|
|
|
+ // configs: defaultResConfigs,
|
|
|
+ // start: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ // end: time.Date(2025, time.May, 3, 0, 10, 0, 0, time.UTC),
|
|
|
+ // intevalKey: "10m",
|
|
|
+ // startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ // },
|
|
|
+ // "1h": {
|
|
|
+ // configs: defaultResConfigs,
|
|
|
+ // start: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ // end: time.Date(2025, time.May, 3, 1, 0, 0, 0, time.UTC),
|
|
|
+ // intevalKey: "1h",
|
|
|
+ // startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ // },
|
|
|
+ // "1d": {
|
|
|
+ // configs: defaultResConfigs,
|
|
|
+ // start: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ // end: time.Date(2025, time.May, 4, 0, 10, 0, 0, time.UTC),
|
|
|
+ // intevalKey: "1d",
|
|
|
+ // startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ // },
|
|
|
+ // "2m": {
|
|
|
+ // configs: defaultResConfigs,
|
|
|
+ // start: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ // end: time.Date(2025, time.May, 3, 0, 2, 0, 0, time.UTC),
|
|
|
+ // intevalKey: "10m",
|
|
|
+ // startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ // },
|
|
|
+ // "2m offset": {
|
|
|
+ // configs: defaultResConfigs,
|
|
|
+ // start: time.Date(2025, time.May, 3, 0, 9, 0, 0, time.UTC),
|
|
|
+ // end: time.Date(2025, time.May, 3, 0, 11, 0, 0, time.UTC),
|
|
|
+ // intevalKey: "10m",
|
|
|
+ // startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ // },
|
|
|
+ "24h": {
|
|
|
configs: defaultResConfigs,
|
|
|
- start: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
- end: time.Date(2025, time.May, 3, 1, 0, 0, 0, time.UTC),
|
|
|
+ start: *win24h.Start(),
|
|
|
+ end: *win24h.End(),
|
|
|
intevalKey: "1h",
|
|
|
- startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
- },
|
|
|
- "1d": {
|
|
|
- configs: defaultResConfigs,
|
|
|
- start: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
- end: time.Date(2025, time.May, 4, 0, 10, 0, 0, time.UTC),
|
|
|
- intevalKey: "1d",
|
|
|
- startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
- },
|
|
|
- "2m": {
|
|
|
- configs: defaultResConfigs,
|
|
|
- start: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
- end: time.Date(2025, time.May, 3, 0, 2, 0, 0, time.UTC),
|
|
|
- intevalKey: "10m",
|
|
|
- startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
- },
|
|
|
- "2m offset": {
|
|
|
- configs: defaultResConfigs,
|
|
|
- start: time.Date(2025, time.May, 3, 0, 9, 0, 0, time.UTC),
|
|
|
- end: time.Date(2025, time.May, 3, 0, 11, 0, 0, time.UTC),
|
|
|
- intevalKey: "10m",
|
|
|
- startKey: time.Date(2025, time.May, 3, 0, 0, 0, 0, time.UTC),
|
|
|
+ startKey: *win24h.Start(),
|
|
|
},
|
|
|
}
|
|
|
for name, tt := range tests {
|
|
|
@@ -72,7 +82,7 @@ func Test_repoStoreProvider_getStoreKeys(t *testing.T) {
|
|
|
t.Errorf("getStoreKeys() got = %v, want %v", intevalKey, tt.intevalKey)
|
|
|
}
|
|
|
if !reflect.DeepEqual(startKey, tt.startKey) {
|
|
|
- t.Errorf("getStoreKeys() got1 = %v, want %v", startKey, tt.startKey)
|
|
|
+ t.Errorf("getStoreKeys() got = %v, want %v", startKey, tt.startKey)
|
|
|
}
|
|
|
})
|
|
|
}
|