defmodule SimpleshopTheme.Clients.PrintfulTest do use ExUnit.Case, async: true alias SimpleshopTheme.Clients.Printful describe "api_token/0" do test "reads from process dictionary when set" do Process.put(:printful_api_key, "test_token_123") assert Printful.api_token() == "test_token_123" after Process.delete(:printful_api_key) end test "raises when no token available" do Process.delete(:printful_api_key) _original = System.get_env("PRINTFUL_API_TOKEN") System.delete_env("PRINTFUL_API_TOKEN") assert_raise RuntimeError, ~r/PRINTFUL_API_TOKEN/, fn -> Printful.api_token() end after Process.delete(:printful_api_key) # Restore env if it was set case System.get_env("PRINTFUL_API_TOKEN") do nil -> :ok _ -> :ok end end end describe "store_id/0" do test "reads from process dictionary" do Process.put(:printful_store_id, 12345) assert Printful.store_id() == 12345 after Process.delete(:printful_store_id) end test "returns nil when not set" do Process.delete(:printful_store_id) assert Printful.store_id() == nil end end end