| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- package filter_test
- // import (
- // "github.com/opencost/opencost/pkg/kubecost"
- // "testing"
- // "time"
- // )
- // type windowedImpl struct {
- // kubecost.Window
- // }
- // func (w *windowedImpl) GetWindow() kubecost.Window {
- // return w.Window
- // }
- // func newWindowedImpl(start, end *time.Time) *windowedImpl {
- // return &windowedImpl{kubecost.NewWindow(start, end)}
- // }
- // func Test_WindowContains_Matches(t *testing.T) {
- // noon := time.Date(2022, 9, 29, 12, 0, 0, 0, time.UTC)
- // one := noon.Add(time.Hour)
- // two := one.Add(time.Hour)
- // three := two.Add(time.Hour)
- // cases := map[string]struct {
- // windowed *windowedImpl
- // filter Filter[*windowedImpl]
- // expected bool
- // }{
- // "fully contains": {
- // windowed: newWindowedImpl(&one, &two),
- // filter: WindowCondition[*windowedImpl]{
- // Window: kubecost.NewWindow(&noon, &three),
- // Op: WindowContains,
- // },
- // expected: true,
- // },
- // "window matches": {
- // windowed: newWindowedImpl(&one, &two),
- // filter: WindowCondition[*windowedImpl]{
- // Window: kubecost.NewWindow(&one, &two),
- // Op: WindowContains,
- // },
- // expected: true,
- // },
- // "contains start": {
- // windowed: newWindowedImpl(&one, &three),
- // filter: WindowCondition[*windowedImpl]{
- // Window: kubecost.NewWindow(&noon, &two),
- // Op: WindowContains,
- // },
- // expected: false,
- // },
- // "contains end": {
- // windowed: newWindowedImpl(&noon, &two),
- // filter: WindowCondition[*windowedImpl]{
- // Window: kubecost.NewWindow(&one, &three),
- // Op: WindowContains,
- // },
- // expected: false,
- // },
- // "window start = filter end": {
- // windowed: newWindowedImpl(&one, &two),
- // filter: WindowCondition[*windowedImpl]{
- // Window: kubecost.NewWindow(&noon, &one),
- // Op: WindowContains,
- // },
- // expected: false,
- // },
- // "window end = filter start": {
- // windowed: newWindowedImpl(&noon, &one),
- // filter: WindowCondition[*windowedImpl]{
- // Window: kubecost.NewWindow(&one, &two),
- // Op: WindowContains,
- // },
- // expected: false,
- // },
- // "window before": {
- // windowed: newWindowedImpl(&noon, &one),
- // filter: WindowCondition[*windowedImpl]{
- // Window: kubecost.NewWindow(&two, &three),
- // Op: WindowContains,
- // },
- // expected: false,
- // },
- // "window after": {
- // windowed: newWindowedImpl(&two, &three),
- // filter: WindowCondition[*windowedImpl]{
- // Window: kubecost.NewWindow(&noon, &one),
- // Op: WindowContains,
- // },
- // expected: false,
- // },
- // }
- // for name, c := range cases {
- // result := c.filter.Matches(c.windowed)
- // if result != c.expected {
- // t.Errorf("%s: expected %t, got %t", name, c.expected, result)
- // }
- // }
- // }
|