From ec8a631d311e052ae37f5ef740acbd60babf169a Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Mon, 31 Jul 2023 16:57:08 +0300 Subject: [PATCH] [#542] Update test for `SizeInBytesSafe` function Signed-off-by: Anton Nikiforov --- cmd/frostfs-node/config/cast_test.go | 5 +++++ cmd/frostfs-node/config/test/config.json | 9 +++++++-- cmd/frostfs-node/config/test/config.yaml | 9 +++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cmd/frostfs-node/config/cast_test.go b/cmd/frostfs-node/config/cast_test.go index ef48bdc5..f8c1ee28 100644 --- a/cmd/frostfs-node/config/cast_test.go +++ b/cmd/frostfs-node/config/cast_test.go @@ -125,10 +125,15 @@ func TestSizeInBytes(t *testing.T) { ) configtest.ForEachFileType("test/config", func(c *config.Config) { c = c.Sub("sizes") + require.EqualValues(t, 1, config.SizeInBytesSafe(c, "size_b")) + require.EqualValues(t, kb, config.SizeInBytesSafe(c, "size_k")) require.EqualValues(t, kb, config.SizeInBytesSafe(c, "size_kb")) require.EqualValues(t, 2*kb, config.SizeInBytesSafe(c, "size_kb_no_space")) + require.EqualValues(t, 12*mb, config.SizeInBytesSafe(c, "size_m")) require.EqualValues(t, 12*mb, config.SizeInBytesSafe(c, "size_mb")) + require.EqualValues(t, 4*gb, config.SizeInBytesSafe(c, "size_g")) require.EqualValues(t, 4*gb, config.SizeInBytesSafe(c, "size_gb")) + require.EqualValues(t, 5*tb, config.SizeInBytesSafe(c, "size_t")) require.EqualValues(t, 5*tb, config.SizeInBytesSafe(c, "size_tb")) require.EqualValues(t, 12, config.SizeInBytesSafe(c, "size_i_am_not_very_clever")) require.EqualValues(t, tb/2, config.SizeInBytesSafe(c, "size_float")) diff --git a/cmd/frostfs-node/config/test/config.json b/cmd/frostfs-node/config/test/config.json index 45635c7a..7eec1b73 100644 --- a/cmd/frostfs-node/config/test/config.json +++ b/cmd/frostfs-node/config/test/config.json @@ -49,10 +49,15 @@ }, "sizes": { + "size_b": "1b", + "size_k": "1 k", "size_kb": "1 kb", "size_kb_no_space": "2kb", - "size_mb": "12m", - "size_gb": "4g", + "size_m": "12m", + "size_mb": "12mb", + "size_g": "4g", + "size_gb": "4gb", + "size_t": "5 T", "size_tb": "5 TB", "size_float": ".5t", "size_float_big": "14.123 gb", diff --git a/cmd/frostfs-node/config/test/config.yaml b/cmd/frostfs-node/config/test/config.yaml index 102c045a..3ae459ea 100644 --- a/cmd/frostfs-node/config/test/config.yaml +++ b/cmd/frostfs-node/config/test/config.yaml @@ -42,10 +42,15 @@ bool: incorrect: not true sizes: + size_b: 1b + size_k: 1 k size_kb: 1 kb size_kb_no_space: 2kb - size_mb: 12m - size_gb: 4g + size_m: 12m + size_mb: 12mb + size_g: 4g + size_gb: 4gb + size_t: 5 T size_tb: 5 TB size_float: .5t size_float_big: 14.123 gb