[#542] Update test for SizeInBytesSafe function

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2023-07-31 16:57:08 +03:00 committed by Evgenii Stratonikov
parent 9ca63ac8c3
commit ec8a631d31
3 changed files with 19 additions and 4 deletions

View file

@ -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"))

View file

@ -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",

View file

@ -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