Skip to content

Commit

Permalink
provisioner: add sumQuantities tests
Browse files Browse the repository at this point in the history
* add tests for whole addition and subtraction
* add tests for zero addition
* fix test name

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
  • Loading branch information
AlexanderYastrebov committed Dec 5, 2023
1 parent 08ad0c2 commit 1df759c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion provisioner/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,32 @@ CWeOoA==
require.Equal(t, "2022-06-10T10:06:43Z", res)
}

func TestSubQuantity(t *testing.T) {
func TestSumQuantities(t *testing.T) {
for _, tc := range []struct {
name string
template string
expected string
}{
{
name: "whole add zero",
template: `{{ sumQuantities "2" "0" }}`,
expected: "2",
},
{
name: "whole addition",
template: `{{ sumQuantities "2" "3" }}`,
expected: "5",
},
{
name: "whole subtraction",
template: `{{ sumQuantities "2" "-1" }}`,
expected: "1",
},
{
name: "fraction add zero",
template: `{{ sumQuantities "256m" "0" }}`,
expected: "256m",
},
{
name: "whole CPU add fraction",
template: `{{ sumQuantities "2" "256m" }}`,
Expand Down

0 comments on commit 1df759c

Please sign in to comment.