defmodule Dagger.Codegen.ElixirGenerator.EnumRendererTest do
  use Dagger.Codegen.RendererCase, async: true

  alias Dagger.Codegen.ElixirGenerator.EnumRenderer

  test "render enum" do
    auto_assert(
      """
      # This file generated by `dagger_codegen`. Please DO NOT EDIT.
      defmodule Dagger.CacheSharingMode do
        @moduledoc \"""
        Sharing mode of the cache volume.
        \"""

        use Dagger.Core.Base, kind: :enum, name: "CacheSharingMode"

        @type t() :: :SHARED | :PRIVATE | :LOCKED

        @doc \"""
        Shares the cache volume amongst many build pipelines
        \"""
        @spec shared() :: :SHARED
        def shared(), do: :SHARED

        @doc \"""
        Keeps a cache volume for a single build pipeline
        \"""
        @spec private() :: :PRIVATE
        def private(), do: :PRIVATE

        @doc \"""
        Shares the cache volume amongst many build pipelines, but will serialize the writes
        \"""
        @spec locked() :: :LOCKED
        def locked(), do: :LOCKED

        @doc false
        @spec from_string(String.t()) :: t()
        def from_string(string)

        def from_string("SHARED"), do: :SHARED
        def from_string("PRIVATE"), do: :PRIVATE
        def from_string("LOCKED"), do: :LOCKED
      end\
      """ <- render_type(EnumRenderer, "test/fixtures/enums/render-enum.json")
    )
  end
end
