Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / test / unit / arvados_api_client_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6
7 class ArvadosApiClientTest < ActiveSupport::TestCase
8   # We use a mock instead of making real API calls, so there's no need to reset.
9   reset_api_fixtures :after_each_test, false
10
11   test 'successful stubbed api request' do
12     stub_api_calls_with_body '{"foo":"bar","baz":0}'
13     use_token :active
14     resp = ArvadosApiClient.new_or_current.api Link, ''
15     assert_equal Hash, resp.class
16     assert_equal 'bar', resp[:foo]
17     assert_equal 0, resp[:baz]
18   end
19
20   test 'exception if server returns non-JSON' do
21     stub_api_calls_with_invalid_json
22     assert_raises ArvadosApiClient::InvalidApiResponseException do
23       use_token :active
24       resp = ArvadosApiClient.new_or_current.api Link, ''
25     end
26   end
27 end