Project

General

Profile

Download (1.24 KB) Statistics
| Branch: | Tag: | Revision:

foreman-docker / test / functionals / image_search_controller_test.rb @ 5397ee73

1
require 'test_plugin_helper'
2

    
3
class ImageSearchControllerTest < ActionController::TestCase
4
  setup do
5
    @container = FactoryGirl.create(:docker_cr)
6
  end
7

    
8
  [Docker::Error::DockerError, Excon::Errors::Error, Errno::ECONNREFUSED].each do |error|
9
    test 'auto_complete_repository_name catches exceptions on network errors' do
10
      ForemanDocker::Docker.any_instance.expects(:exist?).raises(error)
11
      get :auto_complete_repository_name, { :search => "test", :id => @container.id },
12
          set_session_user
13
      assert_response_is_expected
14
    end
15

    
16
    test 'auto_complete_image_tag catch exceptions on network errors' do
17
      ForemanDocker::Docker.any_instance.expects(:tags).raises(error)
18
      get :auto_complete_image_tag, { :search => "test", :id => @container.id }, set_session_user
19
      assert_response_is_expected
20
    end
21

    
22
    test 'search_repository catch exceptions on network errors' do
23
      ForemanDocker::Docker.any_instance.expects(:search).raises(error)
24
      get :search_repository, { :search => "test", :id => @container.id }, set_session_user
25
      assert_response_is_expected
26
    end
27
  end
28

    
29
  def assert_response_is_expected
30
    assert_response :error
31
    assert response.body.include?('An error occured during repository search:')
32
  end
33
end