defmodule Towerops.Workers.PreseemBaselineWorkerTest do
  use Towerops.DataCase, async: true

  import Towerops.AccountsFixtures
  import Towerops.IntegrationsFixtures
  import Towerops.OrganizationsFixtures

  alias Towerops.Workers.PreseemBaselineWorker

  describe "perform/1" do
    test "runs without errors for org with enabled integration" do
      user = user_fixture()
      org = organization_fixture(user.id)
      _integration = integration_fixture(org.id)

      assert :ok = PreseemBaselineWorker.perform(%Oban.Job{})
    end

    test "handles no integrations" do
      assert :ok = PreseemBaselineWorker.perform(%Oban.Job{})
    end

    test "skips disabled integrations" do
      user = user_fixture()
      org = organization_fixture(user.id)
      _integration = integration_fixture(org.id, %{enabled: false})

      assert :ok = PreseemBaselineWorker.perform(%Oban.Job{})
    end
  end
end
