21700: Install Bundler system-wide in Rails postinst
[arvados.git] / lib / cloud / price_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package cloud
6
7 import (
8         "testing"
9         "time"
10
11         . "gopkg.in/check.v1"
12 )
13
14 func Test(t *testing.T) { TestingT(t) }
15
16 type cloudSuite struct{}
17
18 var _ = Suite(&cloudSuite{})
19
20 func (s *cloudSuite) TestNormalizePriceHistory(c *C) {
21         t0, err := time.Parse(time.RFC3339, "2023-01-01T01:00:00Z")
22         c.Assert(err, IsNil)
23         h := []InstancePrice{
24                 {t0.Add(1 * time.Minute), 1.0},
25                 {t0.Add(4 * time.Minute), 1.2}, // drop: unchanged price
26                 {t0.Add(5 * time.Minute), 1.1},
27                 {t0.Add(3 * time.Minute), 1.2},
28                 {t0.Add(5 * time.Minute), 1.1}, // drop: duplicate
29                 {t0.Add(2 * time.Minute), 1.0}, // drop: out of order, unchanged price
30         }
31         c.Check(NormalizePriceHistory(h), DeepEquals, []InstancePrice{h[2], h[3], h[0]})
32 }