Skip to content

Commit 23dc3df

Browse files
committed
Update pricing (fix #294)
1 parent 0e8f50e commit 23dc3df

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address'
11661166
* `scw info` Use json fingerprint field exposed by API
11671167
* Allow to override Region and Architecture when using the helpers to create a new volume from a human size
11681168
* Do not check permissions on config file under Windows ([#282](https://github.com/scaleway/scaleway-cli/pull/282)) ([@ElNounch](https://github.com/ElNounch))
1169+
* Update pricing ([#294](https://github.com/scaleway/scaleway-cli/issues/294))
11691170

11701171
View full [commits list](https://github.com/scaleway/scaleway-cli/compare/v1.7.1...master)
11711172

pkg/pricing/basket_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,36 @@ func TestBasket_Total(t *testing.T) {
5555
So(err, ShouldBeNil)
5656
So(basket.Total(), ShouldEqualBigRat, big.NewRat(24, 1000)) // 0.024
5757
})
58+
Convey("1 server of each type", func() {
59+
basket := NewBasket()
60+
So(basket, ShouldNotBeNil)
61+
So(basket.Total(), ShouldEqualBigRat, ratZero)
62+
63+
basket.Add(NewUsageByPath("/compute/c1/run"))
64+
basket.Add(NewUsageByPath("/compute/c2s/run"))
65+
basket.Add(NewUsageByPath("/compute/c2m/run"))
66+
basket.Add(NewUsageByPath("/compute/c2l/run"))
67+
basket.Add(NewUsageByPath("/compute/vc1/run"))
68+
69+
basket.SetDuration(1 * time.Minute)
70+
So(basket.Total(), ShouldEqualBigRat, big.NewRat(100, 1000)) // 0.1
71+
72+
basket.SetDuration(1 * time.Hour)
73+
So(basket.Total(), ShouldEqualBigRat, big.NewRat(100, 1000)) // 0.1
74+
75+
basket.SetDuration(2 * time.Hour)
76+
So(basket.Total(), ShouldEqualBigRat, big.NewRat(200, 1000)) // 0.2
77+
78+
basket.SetDuration(24 * time.Hour)
79+
So(basket.Total(), ShouldEqualBigRat, big.NewRat(2400, 1000)) // 2.4
80+
81+
basket.SetDuration(30 * 24 * time.Hour)
82+
So(basket.Total(), ShouldEqualBigRat, big.NewRat(50000, 1000)) // 50
83+
84+
// FIXME: this test if false, the capacity is per month
85+
basket.SetDuration(365 * 24 * time.Hour)
86+
So(basket.Total(), ShouldEqualBigRat, big.NewRat(50000, 1000)) // 40
87+
})
5888
Convey("1 compute instance with 2 volumes and 1 ip", func() {
5989
basket := NewBasket()
6090

pkg/pricing/pricing.go

+36
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,42 @@ func init() {
3636
UnitPriceCap: big.NewRat(1000, 1000), // 1
3737
UsageGranularity: time.Minute,
3838
},
39+
{
40+
Path: "/compute/c2s/run",
41+
Identifier: "aaaaaaaa-aaaa-4aaa-8aaa-222222222222",
42+
Currency: "EUR",
43+
UnitPrice: big.NewRat(20, 1000), // 0.02
44+
UnitQuantity: big.NewRat(60000, 1000), // 60
45+
UnitPriceCap: big.NewRat(10000, 1000), // 10
46+
UsageGranularity: time.Minute,
47+
},
48+
{
49+
Path: "/compute/c2m/run",
50+
Identifier: "aaaaaaaa-aaaa-4aaa-8aaa-444444444444",
51+
Currency: "EUR",
52+
UnitPrice: big.NewRat(32, 1000), // 0.032
53+
UnitQuantity: big.NewRat(60000, 1000), // 60
54+
UnitPriceCap: big.NewRat(16000, 1000), // 16
55+
UsageGranularity: time.Minute,
56+
},
57+
{
58+
Path: "/compute/c2l/run",
59+
Identifier: "aaaaaaaa-aaaa-4aaa-8aaa-333333333333",
60+
Currency: "EUR",
61+
UnitPrice: big.NewRat(44, 1000), // 0.044
62+
UnitQuantity: big.NewRat(60000, 1000), // 60
63+
UnitPriceCap: big.NewRat(22000, 1000), // 22
64+
UsageGranularity: time.Minute,
65+
},
66+
{
67+
Path: "/compute/vc1/run",
68+
Identifier: "cccccccc-6ab1-4131-a35e-000000000001",
69+
Currency: "EUR",
70+
UnitPrice: big.NewRat(2, 1000), // 0.002
71+
UnitQuantity: big.NewRat(60000, 1000), // 60
72+
UnitPriceCap: big.NewRat(1000, 1000), // 1
73+
UsageGranularity: time.Minute,
74+
},
3975
{
4076
Path: "/ip/dynamic",
4177
Identifier: "467116bf-4631-49fb-905b-e07701c21111",

0 commit comments

Comments
 (0)