Sha256: ab2a411f70aedd5578ab46a7849f0d410fc9bfbaa9731bf4a21e369b4865bffb

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

require 'helper'

module Bixby
module Test

class TestCommandResponse < MiniTest::Unit::TestCase

  def test_from_json_response
    res = JsonResponse.new("fail", "unknown")
    assert res.fail?
    refute res.success?
    cr = CommandResponse.from_json_response(res)
    assert_kind_of CommandResponse, cr
    assert_equal 255, cr.status
    assert_equal "unknown", cr.stderr
    begin
      cr.raise!
    rescue CommandException => ex
      assert_equal "unknown", ex.message
    end

    res = JsonResponse.new("success", nil, {:status => 0, :stdout => "foobar", :stderr => nil})
    assert res.success?
    refute res.fail?
    cr = CommandResponse.from_json_response(res)
    assert_kind_of CommandResponse, cr
    assert_equal 0, cr.status
    assert_equal "foobar", cr.stdout
    assert_nil cr.stderr
  end

  def test_status
    cr = CommandResponse.new
    cr.status = 0
    assert cr.success?
    refute cr.fail?
    refute cr.error?

    cr.status = "255"
    refute cr.success?
    assert cr.fail?
  end

end # TestCommandResponse

end # Test
end # Bixby

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
bixby-common-0.4.4 test/command_response_test.rb
bixby-common-0.4.3 test/command_response_test.rb
bixby-common-0.4.2 test/command_response_test.rb
bixby-common-0.4.1 test/command_response_test.rb
bixby-common-0.4.0 test/command_response_test.rb
bixby-common-0.3.16 test/command_response_test.rb
bixby-common-0.3.15 test/command_response_test.rb
bixby-common-0.3.14 test/command_response_test.rb
bixby-common-0.3.13 test/command_response_test.rb
bixby-common-0.3.12 test/command_response_test.rb
bixby-common-0.3.11 test/command_response_test.rb
bixby-common-0.3.10 test/command_response_test.rb
bixby-common-0.3.9 test/command_response_test.rb
bixby-common-0.3.8 test/command_response_test.rb