<commit_before>require sprintf('%s/../../../path_helper', File.dirname(File.expand_path(__FILE__)))

require 'rouster'
require 'rouster/puppet'
require 'test/unit'

# this is technically a unit test, no need for a real Rouster VM

class TestGetPuppetStar < Test::Unit::TestCase

  def setup
    assert_nothing_raised do
      @app = Rouster.new(:name => 'app')
    end

    # expose private methods
    Rouster.send(:public, *Rouster.protected_instance_methods)
  end

  def test_happy_get_errors

    output = "[1;35merr: Could not retrieve catalog from remote server: Error 400 on SERVER: no result for [api_vip] in Hiera (YAML/CMS)[0m\nfizzybang\n[1;35merr: Could not retrieve catalog from remote server: Error 400 on SERVER: no result for [foobar] in Hiera (YAML/CMS)[0m"
    @app.output.push(output)

    assert_not_nil(@app.get_puppet_errors())
    assert_equal(2, @app.get_puppet_errors().size)

    assert_nil(@app.get_puppet_notices())

  end

  def test_happy_get_notices

    output = "[0;36mnotice: Not using cache on failed catalog[0m\nfizzbang\n[0;36mnotice: Not using cache on failed catalog[0m"
    @app.output.push(output)

    assert_not_nil(@app.get_puppet_notices())
    assert_equal(2, @app.get_puppet_notices().size)

    assert_nil(@app.get_puppet_errors())

  end

  def test_no_errors

    output = 'there are no errors here'
    @app.output.push(output)<commit_msg>adding tests to support feature #44<commit_after>require sprintf('%s/../../../path_helper', File.dirname(File.expand_path(__FILE__)))

require 'rouster'
require 'rouster/puppet'
require 'test/unit'

# this is technically a unit test, no need for a real Rouster VM

class TestGetPuppetStar < Test::Unit::TestCase

  def setup
    assert_nothing_raised do
      @app = Rouster.new(:name => 'app')
    end

    # expose private methods
    Rouster.send(:public, *Rouster.protected_instance_methods)
  end

  def test_happy_get_errors

    output = "[1;35merr: Could not retrieve catalog from remote server: Error 400 on SERVER: no result for [api_vip] in Hiera (YAML/CMS)[0m\nfizzybang\n[1;35merr: Could not retrieve catalog from remote server: Error 400 on SERVER: no result for [foobar] in Hiera (YAML/CMS)[0m"
    @app.output.push(output)

    assert_not_nil(@app.get_puppet_errors())
    assert_equal(2, @app.get_puppet_errors().size)
    assert_equal(@app.get_puppet_errors(), @app.get_puppet_errors(output)) # could be split out to a different test

    assert_nil(@app.get_puppet_notices())

  end

  def test_happy_get_notices

    output = "[0;36mnotice: Not using cache on failed catalog[0m\nfizzbang\n[0;36mnotice: Not using cache on failed catalog[0m"
    @app.output.push(output)

    assert_not_nil(@app.get_puppet_notices())
    assert_equal(2, @app.get_puppet_notices().size)
    assert_equal(@app.get_puppet_notices(), @app.get_puppet_notices(output))

    assert_nil(@app.get_puppet_errors())

  end

  def test_no_errors

    output = 'there are no errors here'
    @app.output.push(output)
{'fraction_non_alphanumeric': 0.11447587354409318, 'fraction_numerical': 0.016638935108153077, 'mean_word_length': 4.435804701627487, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2359455', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1038, 'n_words': 248}