Project

General

Profile

Revision 2b80fdd9

Added by Ori Rabin almost 6 years ago

Fixes #13043 - Change Parameter inheritance to DockerParameter

View differences:

test/functionals/containers_steps_controller_test.rb
43 43
        :docker_container_wizard_state_id => state.id
44 44
      }
45 45
      state.environment = DockerContainerWizardStates::Environment.create!(environment_options)
46
      state.environment.exposed_ports.create!(:name => '1654', :value => 'tcp')
47
      state.environment.exposed_ports.create!(:name => '1655', :value => 'udp')
46
      state.environment.exposed_ports.create!(:key => '1654', :value => 'tcp')
47
      state.environment.exposed_ports.create!(:key => '1655', :value => 'udp')
48 48
      get :show, { :wizard_state_id => state.id, :id => :environment }, set_session_user
49 49
      assert response.body.include?("1654")
50 50
      assert response.body.include?("1655")
51 51

  
52 52
      # Load ExposedPort variables into container
53 53
      state.environment.exposed_ports.each do |e|
54
        @container.exposed_ports.build :name => e.name,
55
                                       :value => e.value,
56
                                       :priority => e.priority
54
        @container.exposed_ports.build :key => e.key,
55
                                       :value => e.value
57 56
      end
58 57
      # Check if parametrized value of container matches Docker API's expectations
59 58
      assert @container.parametrize.key? "ExposedPorts"
......
67 66
        :docker_container_wizard_state_id => state.id
68 67
      }
69 68
      state.environment = DockerContainerWizardStates::Environment.create!(environment_options)
70
      state.environment.dns.create!(:name => '18.18.18.18')
71
      state.environment.dns.create!(:name => '19.19.19.19')
69
      state.environment.dns.create!(:key => '18.18.18.18')
70
      state.environment.dns.create!(:key => '19.19.19.19')
72 71
      get :show, { :wizard_state_id => state.id, :id => :environment }, set_session_user
73 72
      assert response.body.include?("18.18.18.18")
74 73
      assert response.body.include?("19.19.19.19")
75 74

  
76 75
      # Load Dns variables into container
77 76
      state.environment.dns.each do |e|
78
        @container.dns.build :name => e.name,
79
                             :priority => e.priority
77
        @container.dns.build :key => e.key
80 78
      end
81 79
      # Check if parametrized value of container matches Docker API's expectations
82 80
      assert @container.parametrize.key? "HostConfig"
83 81
      assert @container.parametrize["HostConfig"].key? "Dns"
84 82
      assert @container.parametrize["HostConfig"].value? ["18.18.18.18", "19.19.19.19"]
85 83
    end
84

  
85
    test "does not create a container with 2 exposed ports with the same key" do
86
      state = DockerContainerWizardState.new
87
      environment_options = {
88
          :docker_container_wizard_state_id => state.id
89
      }
90
      state.environment = DockerContainerWizardStates::Environment.new(environment_options)
91
      state.environment.exposed_ports.new(:key => '1654', :value => 'tcp')
92
      state.environment.exposed_ports.new(:key => '1654', :value => 'udp')
93
      refute_valid state
94
      assert_equal "Please ensure the following parameters are unique", state.errors[:'environment.exposed_ports'].first
95
    end
86 96
  end
87 97
end

Also available in: Unified diff