diff --git a/test/dwyl_cid_test.exs b/test/dwyl_cid_test.exs deleted file mode 100644 index df9d765..0000000 --- a/test/dwyl_cid_test.exs +++ /dev/null @@ -1,32 +0,0 @@ -defmodule DwylCidTest do - use ExUnit.Case - doctest DwylCid - - test "Creates a deterministic Content ID from Elixir String" do - assert DwylCid.make("Elixir") == "NSqJspBr2u1F6z1DhcR2cnQAxLdQZBLk" - end - - test "Create a CID from a Map" do - map = %{cat: "Meow", dog: "Woof", fox: "What Does The Fox Say?"} - assert DwylCid.make(map) == "GdrVnsLSdxRphXgQgNsmq1FDyRXAySXT" - end - - test "DwylCid.make(\"hello world\")" do - assert DwylCid.make("hello world") == "MJ7MSJwS1utMxA9QyQLytNDtd5RGnx6m" - end - - test "DwylCid.cid returns the same CID as IPFS when given a string" do - {:ok, cid} = DwylCid.cid("Hello World") - assert cid == "zb2rhkpbfTBtUV1ESqSScrUre8Hh77fhCKDLmX21rCo5xp8J9" - end - - test "DwylCid.cid returns the same CID as IPFS when given a map" do - {:ok, cid} = DwylCid.cid(%{a: "a"}) - assert cid == "zb2rhbYzyUJP6euwn89vAstfgG2Au9BSwkFGUJkbujWztZWjZ" - end - - test "DwylCid.cid returns the same CID as IPFS when given a struct" do - {:ok, cid} = DwylCid.cid(%DwylCid{a: "a"}) - assert cid == "zb2rhbYzyUJP6euwn89vAstfgG2Au9BSwkFGUJkbujWztZWjZ" - end -end diff --git a/test/ex_cid_test.exs b/test/ex_cid_test.exs new file mode 100644 index 0000000..55b7257 --- /dev/null +++ b/test/ex_cid_test.exs @@ -0,0 +1,25 @@ +defmodule ExCidTest do + use ExUnit.Case + doctest ExCid + + defstruct [:a] + + describe "Testing ex_cid function" do + + test "ExCid.cid returns the same CID as IPFS when given a string" do + assert "zb2rhkpbfTBtUV1ESqSScrUre8Hh77fhCKDLmX21rCo5xp8J9" == ExCid.cid("Hello World") + end + + test "ExCid.cid returns the same CID as IPFS when given a map" do + assert "zb2rhbYzyUJP6euwn89vAstfgG2Au9BSwkFGUJkbujWztZWjZ" == ExCid.cid(%{a: "a"}) + end + + test "ExCid.cid returns the same CID as IPFS when given a struct" do + assert "zb2rhbYzyUJP6euwn89vAstfgG2Au9BSwkFGUJkbujWztZWjZ" == ExCid.cid(%__MODULE__{a: "a"}) + end + + test "DwylCid.cid returns an error if given invalid data type" do + assert ExCid.cid(2) == "invalid data type" + end + end +end