Project

General

Profile

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

foreman-docker / test / units / containers_service_test.rb @ 7ff105d1

1
require 'test_plugin_helper'
2

    
3
class ContainersServiceTest < ActiveSupport::TestCase
4
  setup do
5
    @state = DockerContainerWizardState.create! do |s|
6
      s.build_preliminary(:compute_resource_id => FactoryGirl.create(:docker_cr).id,
7
                          :locations           => [taxonomies(:location1)],
8
                          :organizations       => [taxonomies(:organization1)])
9
      s.build_image(:repository_name => 'test', :tag => 'test')
10
      s.build_configuration(:name => 'test', :command => '/bin/bash')
11
      s.build_environment(:tty => false)
12
    end
13
  end
14

    
15
  test 'removes current state after successful container creation' do
16
    ret = OpenStruct.new(:id => 1)
17
    ForemanDocker::Docker.any_instance.expects(:create_image).returns(ret).with do |subject|
18
      subject.must_equal(:fromImage => "test:test")
19
    end
20
    ForemanDocker::Docker.any_instance.expects(:create_container)
21
      .returns(OpenStruct.new(:uuid => 1))
22
    Service::Containers.new.start_container!(@state)
23
    assert_equal DockerContainerWizardState.where(:id => @state.id).count, 0
24
  end
25
end