Skip to content

Commit

Permalink
[#98] Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny committed May 23, 2022
1 parent f3d0e26 commit e94b680
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,37 @@ class UffizziCore::Api::Cli::V1::Projects::ComposeFilesControllerTest < ActionCo

assert_response :not_found
end

test '#create - with yaml aliases' do
sign_in @admin

@compose_file.destroy!
create(:credential, :docker_hub, :active, account: @account)
base_attributes = attributes_for(:compose_file).slice(:source, :path)
file_content = File.read('test/fixtures/files/uffizzi-compose-with_alias.yml')
encoded_content = Base64.encode64(file_content)
compose_file_attributes = base_attributes.merge(content: encoded_content, repository_id: nil)
dependency = {
path: 'configs/vote.conf',
source: 'vote.conf',
content: json_fixture('files/compose_dependencies/configs/vote_conf.json')[:content],
}

params = {
project_slug: @project.slug,
compose_file: compose_file_attributes,
dependencies: [dependency],
}

differences = {
-> { UffizziCore::ComposeFile.main.count } => 1,
-> { UffizziCore::Template.with_creation_source(UffizziCore::Template.creation_source.compose_file).count } => 1,
}

assert_difference differences do
post :create, params: params, format: :json
end

assert_response :success
end
end
25 changes: 25 additions & 0 deletions core/test/fixtures/files/uffizzi-compose-with_alias.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
x-nginx-configs: &nginx-configs
- source: vote_conf
target: /etc/nginx/conf.d

x-srv-nginx: &srv-nginx
nginx:
image: nginx:latest
configs: *nginx-configs
entrypoint: /usr/sbin/nginx-debug
command:
- "-g"
- "daemon off;"

services:
<<: *srv-nginx

x-uffizzi-ingress:
service: nginx
port: 8080

configs:
vote_conf:
file: configs/vote.conf
defaulf_conf:
file: config_files/config_file.conf

0 comments on commit e94b680

Please sign in to comment.