<commit_before>require_relative 'helper'

class TestIgnore < TestWithBasicSetup
  @@command_add     = 'ignore add'
  @@command_remove  = 'ignore remove'
  @@command_current = 'ignore current'
  @@command_clear   = 'ignore clear'

  def test_config_add_should_display_usage
    exit_status, is_usage = output_usage?(@@command_add)
    assert_not_equal 0, exit_status
    assert_true      is_usage
  end

  def test_config_add_should_append_existing_file_to_ignore_file
    file_names = [
      [[              ], 'file1'],
      [['dir1'        ], 'file2'],
      [['dir1', 'dir2'], 'file3'],
    ]
    file_names.each do |dir_names, file_name|
      file = if dir_names.empty?
        file_name
      else
        path = File.join(dir_names)
        FileUtils.mkdir_p(path)
        File.join(path, file_name)
      end
      FileUtils.touch(file)

      exec("#{@@command_add} #{file}")
      contents = File.open(IGNORE_FILE, &:read)
      assert_true contents.include?(File.join('.', file))

      FileUtils.rm(file)
      FileUtils.remove_entry(dir_names.first) unless dir_names.empty?
    end
  end

  def test_config_add_should_not_append_non_existing_file_to_ignore_file
    file = 'non_existing_file'
    dir  = 'empty_dir'
    FileUtils.mkdir(dir)

    [file, dir].each do |path|
      exec("#{@@command_add} #{path}")
      contents = File.open(IGNORE_FILE, &:read)
      assert_false contents.include?(File.join('.', path))
    end

    FileUtils.rmdir(dir)
  end

  def test_config_remove_should_display_usage
    exit_status, is_usage = output_usage?(@@command_remove)
    assert_not_equal 0, exit_status
    assert_true      is_usage
  end

  def test_config_remove_should_delete_existing_file_from_ignore_file
  end

  def test_config_remove_should_delete_non_existing_file_from_ignore_file
  end

  def test_config_current_should_replace_ignore_file_with_new_one_mirroring_current_directory_tree
    initial_ignore = File.open(IGNORE_FILE, &:read)

    File.open(IGNORE_FILE, 'w').close
    exec_with_stdin(@@command_current)
    assert_equal initial_ignore, File.open(IGNORE_FILE, &:read)
  end

  def test_config_clear_should_delete_all_contents_from_ignore_file
    exec_with_stdin(@@command_clear)
    assert_true File.zero?(IGNORE_FILE)
  end
end<commit_msg>[Test] Summarize test case (which have not implemented yet)<commit_after>require_relative 'helper'

class TestIgnore < TestWithBasicSetup
  @@command_add     = 'ignore add'
  @@command_remove  = 'ignore remove'
  @@command_current = 'ignore current'
  @@command_clear   = 'ignore clear'

  def test_config_add_should_display_usage
    exit_status, is_usage = output_usage?(@@command_add)
    assert_not_equal 0, exit_status
    assert_true      is_usage
  end

  def test_config_add_should_append_existing_file_to_ignore_file
    file_names = [
      [[              ], 'file1'],
      [['dir1'        ], 'file2'],
      [['dir1', 'dir2'], 'file3'],
    ]
    file_names.each do |dir_names, file_name|
      file = if dir_names.empty?
        file_name
      else
        path = File.join(dir_names)
        FileUtils.mkdir_p(path)
        File.join(path, file_name)
      end
      FileUtils.touch(file)

      exec("#{@@command_add} #{file}")
      contents = File.open(IGNORE_FILE, &:read)
      assert_true contents.include?(File.join('.', file))

      FileUtils.rm(file)
      FileUtils.remove_entry(dir_names.first) unless dir_names.empty?
    end
  end

  def test_config_add_should_not_append_non_existing_file_to_ignore_file
    file = 'non_existing_file'
    dir  = 'empty_dir'
    FileUtils.mkdir(dir)

    [file, dir].each do |path|
      exec("#{@@command_add} #{path}")
      contents = File.open(IGNORE_FILE, &:read)
      assert_false contents.include?(File.join('.', path))
    end

    FileUtils.rmdir(dir)
  end

  def test_config_remove_should_display_usage
    exit_status, is_usage = output_usage?(@@command_remove)
    assert_not_equal 0, exit_status
    assert_true      is_usage
  end

  def test_config_remove_should_delete_file_from_ignore_file
  end

  def test_config_current_should_replace_ignore_file_with_new_one_mirroring_current_directory_tree
    initial_ignore = File.open(IGNORE_FILE, &:read)

    File.open(IGNORE_FILE, 'w').close
    exec_with_stdin(@@command_current)
    assert_equal initial_ignore, File.open(IGNORE_FILE, &:read)
  end

  def test_config_clear_should_delete_all_contents_from_ignore_file
    exec_with_stdin(@@command_clear)
    assert_true File.zero?(IGNORE_FILE)
  end
end
{'fraction_non_alphanumeric': 0.09707446808510638, 'fraction_numerical': 0.0035460992907801418, 'mean_word_length': 3.765575501583949, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2197868', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1521, 'n_words': 256}