Sha256: 2e348d50cf93020a278399642612d33d3fd574a270d515494233cc75208575be

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require_relative '../../processor/main'
require_relative '../../app/mock'

class TestCmdProcessorLoadCmds < Test::Unit::TestCase

  def setup
    @proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
    @proc.instance_variable_set('@settings', {})
  end

  # See that we have can load up commands
  def test_basic
    @proc.load_cmds_initialize
    assert_equal(false, @proc.commands.empty?)
    assert_equal(false, @proc.aliases.empty?)
  end

  def test_complete
    assert_equal(%w(debug delete directory disable disassemble display down),
                 @proc.complete('d', 'd'),
                 "Failed completion of 'd' commands")
    assert_equal(['debug', 'different', 'directories'], 
                 @proc.complete('sho d', 'd'),
                 "Failed completion of 'sho d' subcommands")
    $errors = []
  end

  def test_run_cmd
    $errors = []

    def @proc.errmsg(mess)
      $errors << mess
    end

    def test_it(size, *args)
      @proc.run_cmd(*args)
      assert_equal(size, $errors.size, $errors)
    end
    test_it(1, 'foo')
    test_it(2, [])
    test_it(3, ['list', 5])
    # See that we got different error messages
    assert_not_equal($errors[0], $errors[1], $errors)
    assert_not_equal($errors[1], $errors[2], $errors)
    assert_not_equal($errors[2], $errors[0], $errors)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trepanning-0.1.3 test/unit/test-proc-load_cmds.rb