<commit_before>defmodule Funnel.TransistorTest do
  use Funnel.TestCase, async: true
  use Dynamo.HTTP.Case

  test "transistor is alive" do
    token = "secrettoken"
    conn = conn(:GET, "/?token=#{token}")
    conn.fetch(:params)
    {:ok, transistor} = Funnel.Transistor.start_link(token)
    assert Process.alive?(transistor)
  end

  test "send message from the cache" do
    token = "secrettoken"

    {:ok, cache} = Funnel.Caches.add token
    Funnel.Transistor.Cache.push(cache, 1, "plop")
    Funnel.Transistor.Cache.push(cache, 2, "plop")

    {:ok, transistor} = Funnel.Transistor.start_link(token)
    Funnel.Transistor.add(self, token, 1)

    refute_receive({:chunk, [id: 1, body: "plop"]})
    assert_received({:chunk, [id: 2, body: "plop"]})
  end

  test "send new message" do
    token = "secrettoken"

    {:ok, transistor} = Funnel.Transistor.start_link(token)
    Funnel.Transistor.add(self, token, 1)<commit_msg>[Gardening] Warning on unused variable<commit_after>defmodule Funnel.TransistorTest do
  use Funnel.TestCase, async: true
  use Dynamo.HTTP.Case

  test "transistor is alive" do
    token = "secrettoken"
    conn = conn(:GET, "/?token=#{token}")
    conn.fetch(:params)
    {:ok, transistor} = Funnel.Transistor.start_link(token)
    assert Process.alive?(transistor)
  end

  test "send message from the cache" do
    token = "secrettoken"

    {:ok, cache} = Funnel.Caches.add token
    Funnel.Transistor.Cache.push(cache, 1, "plop")
    Funnel.Transistor.Cache.push(cache, 2, "plop")

    {:ok, _transistor} = Funnel.Transistor.start_link(token)
    Funnel.Transistor.add(self, token, 1)

    refute_receive({:chunk, [id: 1, body: "plop"]})
    assert_received({:chunk, [id: 2, body: "plop"]})
  end

  test "send new message" do
    token = "secrettoken"

    {:ok, _transistor} = Funnel.Transistor.start_link(token)
    Funnel.Transistor.add(self, token, 1)
{'fraction_non_alphanumeric': 0.143384290985767, 'fraction_numerical': 0.0063257775434897206, 'mean_word_length': 3.879177377892031, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2991511', 'n_tokens_mistral': 740, 'n_tokens_neox': 678, 'n_words': 153}