Skip to content

Commit

Permalink
[#273] update tests after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny authored and zipofar committed Oct 6, 2022
1 parent d6b9ca4 commit c08bc16
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,11 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsControllerTest < ActionCon
end

test '#create - with content when compose file does not exist' do
deployment_data = json_fixture('files/controller/deployments.json')
stubbed_deployment_request = stub_controller_get_deployment_request_any(deployment_data)
stubbed_controller_create_deployment_request = stub_controller_create_deployment_request
stub_controller_apply_credential

file_content = File.read('test/fixtures/files/test-compose-success-without-dependencies.yml')
encoded_content = Base64.encode64(file_content)
stub_dockerhub_repository_any
Expand Down Expand Up @@ -837,6 +841,7 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsControllerTest < ActionCon

assert_response :success
assert_requested stubbed_controller_create_deployment_request
assert_requested stubbed_deployment_request

container_keys = [:image, :tag, :service_name, :port, :public]
actual_containers_attributes = UffizziCore::Container.all.map { |c| c.attributes.deep_symbolize_keys.slice(*container_keys) }
Expand Down Expand Up @@ -977,11 +982,11 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentsControllerTest < ActionCon

expected_request_to_controller = {
containers: [expected_app_container, expected_nginx_container],
credentials: [{ id: docker_hub_credential.id }],
credentials: [{ id: docker_hub_credential.id }, { id: @credential.id }],
deployment_url: @deployment.preview_url,
}

stubbed_deploy_containers_request = stub_deploy_containers_request_with_body(@deployment, expected_request_to_controller)
stubbed_deploy_containers_request = stub_deploy_containers_request_with_expected(@deployment, expected_request_to_controller)

post :deploy_containers, params: params, format: :json

Expand Down
28 changes: 0 additions & 28 deletions core/test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,6 @@
t.index ["container_id"], name: "index_container_config_files_on_container_id"
end

create_table "uffizzi_core_container_host_volume_files", force: :cascade do |t|
t.string "source_path"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.bigint "container_id", null: false
t.bigint "host_volume_file_id", null: false
t.index ["container_id"], name: "uf_core_cont_h_v_on_cont"
t.index ["host_volume_file_id"], name: "uf_core_cont_h_v_on_h_v_file"
end

create_table "uffizzi_core_containers", force: :cascade do |t|
t.string "image"
t.string "tag"
Expand Down Expand Up @@ -224,20 +214,6 @@
t.index ["activity_item_id"], name: "index_events_on_activity_item_id"
end

create_table "uffizzi_core_host_volume_files", force: :cascade do |t|
t.string "source"
t.string "path"
t.boolean "is_file"
t.binary "payload"
t.bigint "added_by_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.bigint "project_id", null: false
t.bigint "compose_file_id", null: false
t.index ["compose_file_id"], name: "index_host_volume_file_on_compose_file_id"
t.index ["project_id"], name: "index_host_volume_file_on_project_id"
end

create_table "uffizzi_core_invitations", force: :cascade do |t|
t.text "email", null: false
t.text "token", null: false
Expand Down Expand Up @@ -424,8 +400,4 @@
t.index ["user_id"], name: "index_users_roles_on_user_id"
end

add_foreign_key "uffizzi_core_container_host_volume_files", "uffizzi_core_containers", column: "container_id"
add_foreign_key "uffizzi_core_container_host_volume_files", "uffizzi_core_host_volume_files", column: "host_volume_file_id"
add_foreign_key "uffizzi_core_host_volume_files", "uffizzi_core_compose_files", column: "compose_file_id"
add_foreign_key "uffizzi_core_host_volume_files", "uffizzi_core_projects", column: "project_id"
end
10 changes: 8 additions & 2 deletions core/test/support/controller_stub_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def stub_controller_get_deployment_request(deployment, data = nil)
stub_request(:get, uri).to_return(status: 200, body: data.to_json, headers: { 'Content-Type' => 'application/json' })
end

def stub_controller_get_deployment_request_any(data = nil)
uri = %r{#{Regexp.quote(Settings.controller.url.to_s)}/deployments/[0-9]*}

stub_request(:get, uri).to_return(status: 200, body: data.to_json, headers: { 'Content-Type' => 'application/json' })
end

def stub_delete_controller_deployment_request(deployment)
uri = "#{Settings.controller.url}/deployments/#{deployment.id}"

Expand Down Expand Up @@ -67,12 +73,12 @@ def stub_container_log_request(deployment_id, pod_name, limit, data)
stub_request(:get, uri).to_return(status: 200, body: data.to_json, headers: { 'Content-Type' => 'application/json' })
end

def stub_deploy_containers_request_with_body(deployment, body)
def stub_deploy_containers_request_with_expected(deployment, expected_request)
uri = "#{Settings.controller.url}/deployments/#{deployment.id}/containers"

stub_request(:post, uri).with do |req|
actual_body = JSON.parse(req.body).deep_symbolize_keys.deep_sort
expected_body = body.deep_symbolize_keys.deep_sort
expected_body = expected_request.deep_symbolize_keys.deep_sort

actual_body == expected_body
end
Expand Down
28 changes: 0 additions & 28 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,6 @@
t.index ["container_id"], name: "index_container_config_files_on_container_id"
end

create_table "uffizzi_core_container_host_volume_files", force: :cascade do |t|
t.string "source_path"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.bigint "container_id", null: false
t.bigint "host_volume_file_id", null: false
t.index ["container_id"], name: "uf_core_cont_h_v_on_cont"
t.index ["host_volume_file_id"], name: "uf_core_cont_h_v_on_h_v_file"
end

create_table "uffizzi_core_containers", force: :cascade do |t|
t.string "image"
t.string "tag"
Expand Down Expand Up @@ -224,20 +214,6 @@
t.index ["activity_item_id"], name: "index_events_on_activity_item_id"
end

create_table "uffizzi_core_host_volume_files", force: :cascade do |t|
t.string "source"
t.string "path"
t.boolean "is_file"
t.binary "payload"
t.bigint "added_by_id"
t.bigint "project_id", null: false
t.bigint "compose_file_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["compose_file_id"], name: "index_host_volume_file_on_compose_file_id"
t.index ["project_id"], name: "index_host_volume_file_on_project_id"
end

create_table "uffizzi_core_invitations", force: :cascade do |t|
t.text "email", null: false
t.text "token", null: false
Expand Down Expand Up @@ -424,8 +400,4 @@
t.index ["user_id"], name: "index_users_roles_on_user_id"
end

add_foreign_key "uffizzi_core_container_host_volume_files", "uffizzi_core_containers", column: "container_id"
add_foreign_key "uffizzi_core_container_host_volume_files", "uffizzi_core_host_volume_files", column: "host_volume_file_id"
add_foreign_key "uffizzi_core_host_volume_files", "uffizzi_core_compose_files", column: "compose_file_id"
add_foreign_key "uffizzi_core_host_volume_files", "uffizzi_core_projects", column: "project_id"
end

0 comments on commit c08bc16

Please sign in to comment.