Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

defmodule RabbitMQ.CLI.Formatters.FormatterHelpers do
import RabbitCommon.Records
use Bitwise
import Bitwise

@type error :: {:error, term()} | {:error, integer(), String.t() | [String.t()]}

Expand Down
19 changes: 19 additions & 0 deletions deps/rabbitmq_cli/test/ctl/set_disk_free_limit_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -102,34 +102,53 @@ defmodule SetDiskFreeLimitCommandTest do

@tag limit: 2_097_152
test "run: a valid integer input returns an ok and sets the disk free limit", context do
set_disk_free_limit(@default_limit)
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === context[:limit]

set_disk_free_limit(@default_limit)
end

@tag limit: 2_097_152.0
test "run: a valid non-fractional float input returns an ok and sets the disk free limit",
context do
set_disk_free_limit(@default_limit)
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === round(context[:limit])

set_disk_free_limit(@default_limit)
end

@tag limit: 2_097_152.9
test "run: a valid fractional float input returns an ok and sets the disk free limit",
context do
set_disk_free_limit(@default_limit)
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === context[:limit] |> Float.floor() |> round

set_disk_free_limit(@default_limit)
end

@tag limit: "2097152"
test "run: an integer string input returns an ok and sets the disk free limit", context do
set_disk_free_limit(@default_limit)
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === String.to_integer(context[:limit])

set_disk_free_limit(@default_limit)
end

@tag limit: "2MB"
test "run: an valid unit string input returns an ok and changes the limit", context do
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === 2_000_000

set_disk_free_limit(@default_limit)
end

## ------------------------ run relative command -------------------------------------------
Expand Down