- Escape HEEx template braces in GraphQL/API docs with raw(~S[...]) - Fix test assertions for updated marketing copy and UI text - Extract helper functions in GraphQL resolvers to reduce nesting depth - Create shared ErrorHelpers module for API controllers - Fix ETS race condition in brute force whitelist cache for async tests - Fix property test generators to use ASCII instead of printable unicode - Add alert_severity helper to site_live/show - Update accounts fixtures for explicit user confirmation
60 lines
1.8 KiB
Elixir
60 lines
1.8 KiB
Elixir
defmodule Towerops.Integrations.IntegrationPropertyTest do
|
|
@moduledoc "Property-based tests for Integration changeset validation."
|
|
use Towerops.DataCase
|
|
use ExUnitProperties
|
|
|
|
alias Towerops.Integrations.Integration
|
|
|
|
describe "sync_interval_minutes validation" do
|
|
property "accepts positive integers" do
|
|
check all(interval <- positive_integer(), max_runs: 50) do
|
|
changeset =
|
|
Integration.changeset(%Integration{}, %{
|
|
organization_id: Ecto.UUID.generate(),
|
|
provider: "preseem",
|
|
sync_interval_minutes: interval
|
|
})
|
|
|
|
refute Keyword.has_key?(changeset.errors, :sync_interval_minutes)
|
|
end
|
|
end
|
|
|
|
property "rejects zero and negative values" do
|
|
check all(interval <- integer(-1000..0), max_runs: 30) do
|
|
changeset =
|
|
%Integration{}
|
|
|> Integration.changeset(%{
|
|
organization_id: Ecto.UUID.generate(),
|
|
provider: "preseem",
|
|
sync_interval_minutes: interval
|
|
})
|
|
|> Map.put(:action, :insert)
|
|
|
|
assert Keyword.has_key?(changeset.errors, :sync_interval_minutes)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "provider validation" do
|
|
property "rejects arbitrary strings as provider" do
|
|
valid = MapSet.new(["preseem", "gaiia"])
|
|
|
|
check all(
|
|
provider <- string(:alphanumeric, min_length: 1, max_length: 20),
|
|
not MapSet.member?(valid, provider),
|
|
max_runs: 50
|
|
) do
|
|
changeset =
|
|
%Integration{}
|
|
|> Integration.changeset(%{
|
|
organization_id: Ecto.UUID.generate(),
|
|
provider: provider,
|
|
sync_interval_minutes: 10
|
|
})
|
|
|> Map.put(:action, :insert)
|
|
|
|
assert Keyword.has_key?(changeset.errors, :provider)
|
|
end
|
|
end
|
|
end
|
|
end
|