1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
8 class SerializerTest < ActiveSupport::TestCase
10 assert_equal('{}', HashSerializer.dump({}))
11 assert_equal('{"foo":"bar"}', HashSerializer.dump(foo: 'bar'))
12 assert_equal('{"foo":"bar"}', HashSerializer.dump('foo' => 'bar'))
13 assert_equal('[]', ArraySerializer.dump([]))
14 assert_equal('["foo",{"foo":"bar"}]',
15 ArraySerializer.dump(['foo', 'foo' => 'bar']))
17 ArraySerializer.load(ArraySerializer.dump([:foo])))
18 assert_equal([1,'bar'],
19 ArraySerializer.load(ArraySerializer.dump([1,'bar'])))
22 test 'load array that was saved as json, then mangled by an old version' do
24 ArraySerializer.load(YAML.dump(ArraySerializer.dump(['foo']))))