Create a gist now

Instantly share code, notes, and snippets.

@taybin /nodetest.ex
Last active Aug 29, 2015

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