Skip to content

Instantly share code, notes, and snippets.

@johnhamelink
Created March 2, 2016 01:19
Show Gist options
  • Select an option

  • Save johnhamelink/fbe4f5490b7b1dea9c07 to your computer and use it in GitHub Desktop.

Select an option

Save johnhamelink/fbe4f5490b7b1dea9c07 to your computer and use it in GitHub Desktop.
defmodule ExrmDebTest.ConfigTest do
use ExUnit.Case, async: false
import ExUnit.CaptureIO
test "Configuration is sanitized correctly" do
out = ExrmDeb.Utils.Config.sanitize_config(%{ name: "$!JIM-B+O.B,'" })
assert Map.fetch!(out, :sanitized_name)
assert Map.fetch!(out, :sanitized_name) == "jim-b+o.b"
end
test "building default config works correctly" do
assert {:ok, _} = ExrmDeb.Config.build_config
end
test "building an invalid config results in an error being raised" do
capture_io(fn ->
assert {:error, [{:error, :description, :presence, "must be present"}]} =
ExrmDeb.Config.build_config(%{description: nil})
end)
end
test "owner must have both user and group" do
capture_io(fn ->
assert {:error, [{:error, [:owner, :group], :presence, "must be present"}]} =
ExrmDeb.Config.build_config(%{owner: [user: "root"]})
end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment