121f79a4fad2fc78bd9ad74ac17fe5b0dbe06cc5
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / locales_spec.rb
1 require 'spec_helper_acceptance'
2
3 require 'beaker/i18n_helper'
4
5 PUPPETLABS_GPG_KEY_LONG_ID     = '7F438280EF8D349F'.freeze
6 PUPPETLABS_LONG_FINGERPRINT    = '123456781274D2C8A956789A456789A456789A9A'.freeze
7
8 id_doesnt_match_fingerprint_pp = <<-MANIFEST
9         apt_key { '#{PUPPETLABS_LONG_FINGERPRINT}':
10           ensure => 'present',
11           content => '123456781274D2C8A956789A456789A456789A9B',
12         }
13   MANIFEST
14
15 location_not_specified_fail_pp = <<-MANIFEST
16         apt::source { 'puppetlabs':
17           ensure => 'present',
18           repos    => 'main',
19           key      => {
20             id     => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
21             server => 'hkps.pool.sks-keyservers.net',
22           },
23         }
24   MANIFEST
25
26   no_content_param = <<-MANIFEST
27           apt_key { '#{123456781274D2C8A956789A456789A456789A9A}':
28             ensure => 'present',
29           }
30     MANIFEST
31
32 describe 'localization', if: (fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat') && (Gem::Version.new(puppet_version) >= Gem::Version.new('4.10.5')) do
33   before :all do
34     hosts.each do |host|
35       on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
36       change_locale_on(host, 'ja_JP.utf-8')
37     end
38   end
39
40   describe 'ruby translations' do
41     it 'fails with interpolated string' do
42       apply_manifest(id_doesnt_match_fingerprint_pp, expect_failures: true) do |r|
43         expect(r.stderr).to match(%r{を設定できませんでした: マニフェスト123456781274D2C8A956789A456789A456789A9Aに含まれるidと、content/sourceのフィンガープリントが一致しません。idに間違いがないか、content/sourceが正当であるかを確認してください})
44       end
45     end
46     it 'fails with simple string' do
47       apply_manifest(location_not_specified_fail_pp, expect_failures: true) do |r|
48         expect(r.stderr).to match(%r{の検証中にエラーが生じました。Evaluation Error: a Function Callの検証中にエラーが生じました。場所を指定せずにソースエントリを作成することはできません})
49       end
50     end
51   end
52
53   describe 'puppet translations' do
54     it 'fails with interpolated string' do
55       apply_manifest(no_content_param, expect_failures: true) do |r|
56         expect(r.stderr).to match(%r{contentパラメータを渡す必要があります})
57       end
58     end
59     it 'fails with simple string' do
60       apply_manifest(no_content_param, expect_failures: true) do |r|
61         expect(r.stderr).to match(%r{need a test})
62       end
63     end
64   end
65
66   after :all do
67     hosts.each do |host|
68       on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
69       change_locale_on(host, 'en_US')
70     end
71   end
72 end