Skip to content

Commit

Permalink
Change source URL for composer that depend of the channel.
Browse files Browse the repository at this point in the history
initial test for composer
  • Loading branch information
Philippe Beaumont committed May 1, 2022
1 parent 45d56b8 commit c4647f9
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 20 deletions.
8 changes: 6 additions & 2 deletions data/default.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---

lookup_options:
php::fpm::pools:
merge: first

php::composer::channel_sources:
stable: 'https://getcomposer.org/download/latest-stable/composer.phar'
preview: 'https://getcomposer.org/download/latest-preview/composer.phar'
snapshot: 'https://getcomposer.org/composer.phar'
1: 'https://getcomposer.org/download/latest-1.x/composer.phar'
2: 'https://getcomposer.org/download/latest-2.x/composer.phar'
9 changes: 4 additions & 5 deletions manifests/composer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# === Parameters
#
# [*source*]
# Holds URL to the Composer source file
# [*channel_sources*]
# Define channel URLs to the Composer source file
#
# [*path*]
# Holds path to the Composer executable
Expand All @@ -27,7 +27,7 @@
# UNIX group of the root user
#
class php::composer (
String $source = $php::params::composer_source,
Hash $channel_sources = {},
Stdlib::Absolutepath $path = $php::params::composer_path,
Optional[String[1]] $proxy_type = undef,
Optional[String[1]] $proxy_server = undef,
Expand All @@ -40,7 +40,7 @@

archive { 'download composer':
path => $path,
source => $source,
source => $channel_sources.dig($channel),
proxy_type => $proxy_type,
proxy_server => $proxy_server,
}
Expand All @@ -53,7 +53,6 @@
if $auto_update {
class { 'php::composer::auto_update':
max_age => $max_age,
source => $source,
path => $path,
channel => $channel,
proxy_type => $proxy_type,
Expand Down
4 changes: 0 additions & 4 deletions manifests/composer/auto_update.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# [*max_age*]
# Defines number of days after which Composer should be updated
#
# [*source*]
# Holds URL to the Composer source file
#
# [*path*]
# Holds path to the Composer executable
#
Expand All @@ -30,7 +27,6 @@
#
class php::composer::auto_update (
Integer[1] $max_age,
String[1] $source,
Stdlib::Absolutepath $path,
Php::ComposerChannel $channel = 'stable',
Optional[String[1]] $proxy_type = undef,
Expand Down
1 change: 0 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
$ensure = 'present'
$fpm_service_enable = true
$fpm_service_ensure = 'running'
$composer_source = 'https://getcomposer.org/composer.phar'
$composer_path = '/usr/local/bin/composer'
$composer_max_age = 30
$pear_ensure = 'present'
Expand Down
22 changes: 22 additions & 0 deletions spec/classes/php_composer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'php::composer', type: :class do
on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end
let(:pre_condition) { 'class {"php": composer => false}' }

describe 'works without params' do
it { is_expected.to compile.with_all_deps }
end

describe 'when called with no parameters' do
it { is_expected.to contain_file('/usr/local/bin/composer') }
end
end
end
end
2 changes: 1 addition & 1 deletion spec/classes/php_fpm_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
it { is_expected.to contain_class('php::pear') }
end

describe 'when called with no parameters' do # rubocop: disable RSpec/EmptyExampleGroup
describe 'when called with no parameters' do
case facts[:osfamily]
when 'Debian'
case facts[:operatingsystemrelease]
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/php_repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
end
end

describe 'when configuring a package repo' do # rubocop: disable RSpec/EmptyExampleGroup
describe 'when configuring a package repo' do
case facts[:osfamily]
when 'Debian'
case facts[:operatingsystem]
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
it { is_expected.to compile.with_all_deps }
end

describe 'when called with no parameters' do # rubocop: disable RSpec/EmptyExampleGroup
describe 'when called with no parameters' do
case facts[:osfamily]
when 'Suse', 'RedHat', 'CentOS'
it { is_expected.to contain_class('php::global') }
Expand Down Expand Up @@ -127,7 +127,7 @@
end
end

describe 'when called with package_prefix parameter' do # rubocop: disable RSpec/EmptyExampleGroup
describe 'when called with package_prefix parameter' do
package_prefix = 'myphp-'
let(:params) { { package_prefix: package_prefix } }

Expand Down
2 changes: 1 addition & 1 deletion spec/defines/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

describe 'php::config' do
on_supported_os.each do |os, facts|
context "on #{os}" do # rubocop:disable RSpec/EmptyExampleGroup
context "on #{os}" do
let :facts do
facts
end
Expand Down
6 changes: 3 additions & 3 deletions spec/defines/fpm_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

describe 'php::fpm::pool' do
on_supported_os.each do |os, facts|
context "on #{os}" do # rubocop: disable RSpec/EmptyExampleGroup
context "on #{os}" do
let :facts do
facts
end
let(:pre_condition) { 'include php' }

case facts[:os]['name']
when 'Debian'
context 'plain config' do # rubocop: disable RSpec/EmptyExampleGroup
context 'plain config' do
let(:title) { 'unique-name' }
let(:params) { {} }

Expand All @@ -26,7 +26,7 @@
end
end
when 'Ubuntu'
context 'plain config' do # rubocop: disable RSpec/EmptyExampleGroup
context 'plain config' do
let(:title) { 'unique-name' }
let(:params) { {} }

Expand Down

0 comments on commit c4647f9

Please sign in to comment.