<commit_before>defmodule PhxOembed.SessionControllerTest do
  use PhxOembed.ConnCase
  alias PhxOembed.{Endpoint, User}

  setup %{conn: conn} do
    {:ok, conn: put_req_header(conn, "accept", "application/json")}
  end

  test "when the info is correct", %{conn: conn} do
    user = create_user
    params = %{email: user.email, password: <PASSWORD>}
    conn = post(conn, session_path(Endpoint, :create, session: params))
    resp = json_response(conn, :created)
    {:ok, user_as_json } = Poison.encode(user)
    assert String.length(resp["jwt"]) > 0
    assert resp["user"]["email"] == user.email
  end

  test "when the email does not match", %{conn: conn} do

  end

  test "when the password does not match", %{conn: conn} do

  end

  test "when no info matches", %{conn: conn} do

  end

  defp create_user do
    attrs = %{email: "<EMAIL>", password: "password"}
    changeset = User.changeset(%User{}, attrs)
    Repo.insert!(changeset)
  end
end
<commit_msg>add more session controller tests<commit_after>defmodule PhxOembed.SessionControllerTest do
  use PhxOembed.ConnCase
  alias PhxOembed.{Endpoint, User}

  setup %{conn: conn} do
    {:ok, conn: put_req_header(conn, "accept", "application/json")}
  end

  test "when the info is correct", %{conn: conn} do
    user = create_user
    params = %{email: user.email, password: <PASSWORD>}
    conn = post(conn, session_path(Endpoint, :create, session: params))
    resp = json_response(conn, :created)
    {:ok, user_as_json } = Poison.encode(user)
    assert String.length(resp["jwt"]) > 0
    assert resp["user"]["email"] == user.email
  end

  test "when the email does not match", %{conn: conn} do
    user = create_user
    params = %{email: "<EMAIL>", password: <PASSWORD>}
    conn = post(conn, session_path(Endpoint, :create, session: params))
    resp = json_response(conn, :unprocessable_entity)
    assert resp["error"] == "Invalid email or password"
  end

  test "when the password does not match", %{conn: conn} do
    user = create_user
    params = %{email: user.email, password: "<PASSWORD>"}
    conn = post(conn, session_path(Endpoint, :create, session: params))
    resp = json_response(conn, :unprocessable_entity)
    assert resp["error"] == "Invalid email or password"
  end

  test "when no info matches", %{conn: conn} do
    user = create_user
    params = %{email: "<EMAIL>", password: "<PASSWORD>"}
    conn = post(conn, session_path(Endpoint, :create, session: params))
    resp = json_response(conn, :unprocessable_entity)
    assert resp["error"] == "Invalid email or password"
  end

  defp create_user do
    attrs = %{email: "<EMAIL>", password: "password"}
    changeset = User.changeset(%User{}, attrs)
    Repo.insert!(changeset)
  end
end

{'fraction_non_alphanumeric': 0.13785557986870897, 'fraction_numerical': 0.0007293946024799417, 'mean_word_length': 4.060885608856089, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4224503', 'n_tokens_mistral': 902, 'n_tokens_neox': 873, 'n_words': 266}