-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(PDK-1354) Default template ref for custom templates should always be master #677
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
… master
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,16 +152,16 @@ | |
let(:opts_or_uri) { { :'template-url' => 'cli-templates' } } | ||
|
||
it 'returns the specified template' do | ||
expect(template_uri.to_s).to eq("cli-templates##{described_class.default_template_ref}") | ||
expect(template_uri.to_s).to eq('cli-templates#master') | ||
end | ||
end | ||
|
||
context 'and passed windows template-url' do | ||
let(:opts_or_uri) { { :'template-url' => 'C:\cli-templates' } } | ||
let(:opts_or_uri) { { :'template-url' => 'C:\\cli-templates' } } | ||
|
||
it 'returns the specified template' do | ||
allow(Gem).to receive(:win_platform?).and_return(true) | ||
expect(template_uri.to_s).to eq("C:\\cli-templates##{described_class.default_template_ref}") | ||
expect(template_uri.to_s).to eq('C:\\cli-templates#master') | ||
end | ||
end | ||
|
||
|
@@ -229,7 +229,7 @@ | |
let(:opts_or_uri) { 'https://github.com/my/pdk-templates.git' } | ||
|
||
it 'returns the default ref' do | ||
expect(template_uri.git_ref).to eq described_class.default_template_ref | ||
expect(template_uri.git_ref).to eq(described_class.default_template_ref(opts_or_uri)) | ||
end | ||
end | ||
end | ||
|
@@ -302,37 +302,65 @@ | |
end | ||
|
||
describe '.default_template_ref' do | ||
subject { described_class.default_template_ref } | ||
subject { described_class.default_template_ref(uri) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any tests for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only thing I would be looking for is: |
||
|
||
before(:each) do | ||
allow(PDK::Util).to receive(:development_mode?).and_return(development_mode) | ||
end | ||
|
||
context 'with a custom template repo' do | ||
before(:each) do | ||
allow(described_class).to receive(:default_template_url).and_return('custom_template_url') | ||
let(:uri) { described_class.new('https://github.com/my/template') } | ||
|
||
context 'in development mode' do | ||
let(:development_mode) { true } | ||
|
||
it 'returns master' do | ||
is_expected.to eq('master') | ||
end | ||
end | ||
|
||
it 'returns master' do | ||
is_expected.to eq('master') | ||
context 'not in development mode' do | ||
let(:development_mode) { false } | ||
|
||
it 'returns master' do | ||
is_expected.to eq('master') | ||
end | ||
end | ||
end | ||
|
||
context 'with the default template repo' do | ||
before(:each) do | ||
allow(described_class).to receive(:default_template_url).and_return('puppetlabs_template_url') | ||
end | ||
let(:uri) { described_class.default_template_uri } | ||
|
||
context 'not in development mode' do | ||
before(:each) do | ||
allow(PDK::Util).to receive(:development_mode?).and_return(false) | ||
end | ||
let(:development_mode) { false } | ||
|
||
it 'returns the built-in TEMPLATE_REF' do | ||
is_expected.to eq(PDK::TEMPLATE_REF) | ||
end | ||
end | ||
|
||
context 'in development mode' do | ||
before(:each) do | ||
allow(PDK::Util).to receive(:development_mode?).and_return(true) | ||
let(:development_mode) { true } | ||
|
||
it 'returns master' do | ||
is_expected.to eq('master') | ||
end | ||
end | ||
end | ||
|
||
context 'with an explicit nil template' do | ||
let(:uri) { nil } | ||
|
||
context 'not in development mode' do | ||
let(:development_mode) { false } | ||
|
||
it 'returns the built-in TEMPLATE_REF' do | ||
is_expected.to eq(PDK::TEMPLATE_REF) | ||
end | ||
end | ||
|
||
context 'in development mode' do | ||
let(:development_mode) { true } | ||
|
||
it 'returns master' do | ||
is_expected.to eq('master') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a little complex. Maybe this is better (not sure)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think @glennsarti 's guard clause version is clearer.