Skip to content

Commit

Permalink
remove helper module
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleVsteger committed Oct 31, 2024
1 parent 4ead28b commit 6e16044
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 84 deletions.
7 changes: 1 addition & 6 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ defmodule ChannelSpec.MixProject do
elixir: "~> 1.13",
deps: deps(),
docs: docs(),
package: package(),
elixirc_paths: elixirc_paths(Mix.env())
package: package()
]
end

Expand Down Expand Up @@ -52,8 +51,4 @@ defmodule ChannelSpec.MixProject do
formatters: ["html"]
]
end

# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
end
84 changes: 81 additions & 3 deletions test/channel_spec/socket_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -601,17 +601,95 @@ defmodule ChannelSpec.SocketTest do
mod: mod,
tmp_dir: tmp_dir
} do
defmodule LotsOfRefsSchema.MyChannel do
defmodule :"#{mod}.LotsOfRefsSchema" do
@moduledoc """
This specific setup causes `__unresolved_refs` to get into a state that makes the schema
fail to compile. The PR in which this file was introduced switches from `Map.update!` to
`Map.update` with a default and generates a valid schema.
"""

defmodule Base do
@mod_base Module.split(__MODULE__) |> Enum.drop(-1) |> Module.concat()

def schema() do
%{
type: :object,
properties: %{
foo: %{"$ref": :"#{@mod_base}.Foo"},
bar: %{type: :array, items: [%{"$ref": :"#{@mod_base}.Bar"}]},
flim: %{type: :array, items: [%{"$ref": :"#{@mod_base}.Flim"}]}
},
additionalProperties: false
}
end
end

defmodule Flim do
@mod_base Module.split(__MODULE__) |> Enum.drop(-1) |> Module.concat()

def schema() do
%{
type: :object,
properties: %{
flam: %{
oneOf: [
%{type: :null},
%{"$ref": :"#{@mod_base}.Flam"}
]
}
},
additionalProperties: false
}
end
end

defmodule Foo do
def schema() do
%{oneOf: [%{type: :null}, %{type: :string}]}
end
end

defmodule Bar do
@mod_base Module.split(__MODULE__) |> Enum.drop(-1) |> Module.concat()

def schema() do
%{type: :object, properties: %{baz: %{"$ref": :"#{@mod_base}.Baz"}}}
end
end

defmodule Baz do
def schema() do
%{oneOf: [%{type: :string}, %{type: :null}]}
end
end
end

defmodule :"#{mod}.LotsOfRefsSchema.Flam" do
def schema() do
%{
type: :object,
properties: %{
whatever: %{
type: :array,
items: [%{type: :array, items: [%{type: :string}]}]
}
},
additionalProperties: false
}
end
end

defmodule :"#{mod}.MyChannel" do
use ChannelHandler.Router
use ChannelSpec.Operations

operation "foo", payload: %{"$ref": LotsOfRefsSchema.Base}
operation "foo", payload: %{"$ref": :"#{mod}.LotsOfRefsSchema.Base"}
handle "foo", fn _params, _context, socket -> {:noreply, socket} end

subscription "sub", %{type: :integer}
end

defmodule LotsOfRefsSchema do
defmodule :"#{mod}" do

Check warning on line 692 in test/channel_spec/socket_test.exs

View workflow job for this annotation

GitHub Actions / Elixir Unit Tests (1.13.4, 24.3)

function id/1 required by behaviour Phoenix.Socket is not implemented (in module Test1316)
use ChannelSpec.Socket, schema_path: Path.join(tmp_dir, "schema.json")

channel "foo", __MODULE__.MyChannel, schema_file: Path.join(tmp_dir, "schema.json")
Expand Down
75 changes: 0 additions & 75 deletions test/support/test_schema.ex

This file was deleted.

0 comments on commit 6e16044

Please sign in to comment.