diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-08-24 09:54:45 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-08-24 09:54:45 +0000 |
commit | 3e09ac0c10c95bb24a08af62393b4f761e2743d0 (patch) | |
tree | 778dffa2ba8798503fc047db0feef6d65426ea22 /test/test_sink.rb | |
download | dtas-3e09ac0c10c95bb24a08af62393b4f761e2743d0.tar.gz |
Diffstat (limited to 'test/test_sink.rb')
-rw-r--r-- | test/test_sink.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_sink.rb b/test/test_sink.rb new file mode 100644 index 0000000..959bbf0 --- /dev/null +++ b/test/test_sink.rb @@ -0,0 +1,32 @@ +# -*- encoding: binary -*- +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require './test/helper' +require 'dtas/sink' +require 'yaml' + +class TestSink < Minitest::Unit::TestCase + def test_serialize_reload + sink = DTAS::Sink.new + sink.name = "DAC" + hash = sink.to_hsh + assert_kind_of Hash, hash + refute_match(%r{ruby}i, hash.to_yaml, "ruby guts exposed: #{hash}") + + s2 = DTAS::Sink.load(hash) + assert_equal sink.to_hsh, s2.to_hsh + assert_equal hash, s2.to_hsh + end + + def test_name + sink = DTAS::Sink.new + sink.name = "dac1" + assert_equal({"name" => "dac1"}, sink.to_hsh) + end + + def test_inactive_load + orig = { "active" => false }.freeze + tmp = orig.to_yaml + assert_equal orig, YAML.load(tmp) + end +end |