   end
 
   test "show action - found" do
-    provider = %CloudProvider{id: 1, name: "aws", type: "aws", configuration: "{}"}
-    :meck.expect(Repo, :get, 2, provider)
+    provider = CloudProvider.new(%{name: "aws", type: "aws", configuration: "{}"}) |> Repo.insert
 
-    conn = call(Router, :get, "/cloud_providers/1")
+    conn = call(Router, :get, "/cloud_providers/#{provider.id}")
 
     assert conn.status == 200
 
     body = Poison.decode!(conn.resp_body)
 
-    assert body["id"] == 1
+    assert body["id"] == provider.id
   end
 
   test "show action -- not found" do
-    :meck.expect(Repo, :get, 2, nil)
-
     conn = call(Router, :get, "/cloud_providers/1")
 
     assert conn.status == 404
   end
 
   test "create action -- success" do
-    provider = %CloudProvider{id: 1, name: "aws", type: "aws", configuration: "{}"}
-    :meck.expect(Repo, :insert, 1, provider)
-
     conn = call(Router, :post, "/cloud_providers", Poison.encode!(%{name: "aws", type: "aws", configuration: "{}"}), [{"content-type", "application/json"}])
 
     assert conn.status == 201


    assert length(body) == 2

    assert Enum.any?(body, &(&1["id"] == 1))
    assert Enum.any?(body, &(&1["id"] == 2))
    assert Enum.any?(body, &(&1["name"] == "aws"))
    assert Enum.any?(body, &(&1["name"] == "azure"))
    assert Enum.any?(body, &(&1["type"] == "aws"))

    body = Poison.decode!(conn.resp_body)

    assert length(body) == 2
  end

  test "clusters action -- provider has no clusters" do
    provider1 = CloudProvider.new(%{name: "a", type: "a", configuration: "{}"}) |> Repo.insert
    provider2 = CloudProvider.new(%{name: "a", type: "a", configuration: "{}"}) |> Repo.insert
    _cluster1 = EtcdCluster.new(%{etcd_token: "abc125", hosting_provider_id: provider2.id}) |> Repo.insert
