Skip to content

Instantly share code, notes, and snippets.

@taybin
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taybin/3cf9c9f47a800d122632 to your computer and use it in GitHub Desktop.
Save taybin/3cf9c9f47a800d122632 to your computer and use it in GitHub Desktop.
ecto many to many test
defmodule NodeTest do
use ExUnit.Case
test "can have childen and parents" do
node1 = %Node{name: "parent"} |> Repo.insert
node2 = %Node{name: "child2"} |> Repo.insert
%NodeToNode{parent_id: node1.id, child_id: node.id} |> Repo.insert
assert Node.get_children(node1) == [node2]
assert Node.get_parents(node2) == [node1]
end
emd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment