Skip to content

Commit eed69e9

Browse files
committed
(GH-57) Fix bug with i18n in the language server
The code use to do document validation was using the special function `_` which was introduced in Puppet 4.9 for internationalisation. This commit removes the i18n function as it is not required for the language server itself and adds some basic tests to prevent regression.
1 parent 40a10d6 commit eed69e9

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

server/lib/puppet-languageserver/document_validator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def self.validate(content, _max_problems = 100)
4545
Puppet[:code] = content
4646
env = Puppet.lookup(:current_environment)
4747
loaders = Puppet::Pops::Loaders.new(env)
48-
Puppet.override({ :loaders => loaders }, _('For puppet parser validate')) do
48+
Puppet.override({ :loaders => loaders }, 'For puppet parser validate') do
4949
begin
5050
validation_environment = env
5151
validation_environment.check_for_reparse
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'spec_helper'
2+
3+
describe 'document_validator' do
4+
let(:subject) { PuppetLanguageServer::DocumentValidator }
5+
6+
describe '#validate' do
7+
describe "Given an incomplete manifest which has syntax errors" do
8+
let(:manifest) { 'user { "Bob"' }
9+
10+
it "should return at least one error" do
11+
result = subject.validate(manifest)
12+
expect(result.length).to be > 0
13+
end
14+
end
15+
16+
describe "Given a complete manifest with no validation errors" do
17+
let(:manifest) { "user { 'Bob': ensure => 'present' }" }
18+
19+
it "should return an empty array" do
20+
expect(subject.validate(manifest)).to eq([])
21+
end
22+
end
23+
24+
end
25+
end

0 commit comments

Comments
 (0)