<commit_before>require File.expand_path("../helper.rb", __FILE__)

context "QC::Queue" do

  test "queue is a singleton" do
    assert_equal QC::Queue, QC::Queue.instance.class
  end

  test "queue takes a data_store" do
    QC::Queue.instance.setup :data_store => []
    assert_equal [], QC::Queue.instance.instance_variable_get(:@data)
  end

  test "queue repsonds to length" do
    QC::Queue.instance.setup :data_store => []
    QC::Queue.instance.enqueue "job","params"

    assert_equal 1, QC::Queue.instance.length
  end

  test "can delete all" do
    QC::Queue.instance.setup :data_store => []

    QC::Queue.instance.enqueue "job","params"
    QC::Queue.instance.enqueue "job","params"

    assert_equal 2, QC::Queue.instance.length
    QC::Queue.instance.delete_all
    assert_equal 0, QC::Queue.instance.length
  end

  test "query finds jobs with matching signature" do
    QC::Queue.instance.setup(
      :data_store => QC::DurableArray.new(:database => ENV["DATABASE_URL"])
    )

    QC::Queue.instance.enqueue "Notifier.send", "params"

    jobs = QC::Queue.instance.query("Notifier.send")
    assert_equal "Notifier.send", jobs.first.signature
  end
<commit_msg>this is a better way to test this feature<commit_after>require File.expand_path("../helper.rb", __FILE__)

context "QC::Queue" do

  test "queue is a singleton" do
    assert_equal QC::Queue, QC::Queue.instance.class
  end

  test "queue takes a data_store" do
    QC::Queue.instance.setup :data_store => []
    assert_equal [], QC::Queue.instance.instance_variable_get(:@data)
  end

  test "queue repsonds to length" do
    QC::Queue.instance.setup :data_store => []
    QC::Queue.instance.enqueue "job","params"

    assert_equal 1, QC::Queue.instance.length
  end

  test "can delete all" do
    QC::Queue.instance.setup :data_store => []

    QC::Queue.instance.enqueue "job","params"
    QC::Queue.instance.enqueue "job","params"

    assert_equal 2, QC::Queue.instance.length
    QC::Queue.instance.delete_all
    assert_equal 0, QC::Queue.instance.length
  end

  test "query finds jobs with matching signature" do
    QC::Queue.instance.setup(
      :data_store => QC::DurableArray.new(:database => ENV["DATABASE_URL"])
    )
    QC::Queue.instance.delete_all

    QC::Queue.instance.enqueue "Notifier.send", "params"

    jobs = QC::Queue.instance.query("Notifier.send")
    assert_equal 1, jobs.length
    assert_equal "Notifier.send", jobs.first.signature
  end

{'fraction_non_alphanumeric': 0.13691931540342298, 'fraction_numerical': 0.0028524857375713123, 'mean_word_length': 3.91, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6136343', 'n_tokens_mistral': 844, 'n_tokens_neox': 775, 'n_words': 174}