BigW Consortium Gitlab

Commit 35354826 by Grzegorz Bizon

Improve pipeline expressions specs and freeze constants

parent e6498efe
...@@ -7,7 +7,7 @@ module Gitlab ...@@ -7,7 +7,7 @@ module Gitlab
Expression::Variable, Expression::Variable,
Expression::String, Expression::String,
Expression::Equals Expression::Equals
] ].freeze
MAX_CYCLES = 5 MAX_CYCLES = 5
SyntaxError = Class.new(StandardError) SyntaxError = Class.new(StandardError)
......
...@@ -12,7 +12,7 @@ module Gitlab ...@@ -12,7 +12,7 @@ module Gitlab
%w[string equals variable], %w[string equals variable],
%w[null equals variable], %w[null equals variable],
%w[variable] %w[variable]
] ].freeze
def initialize(statement, pipeline) def initialize(statement, pipeline)
@pipeline = pipeline @pipeline = pipeline
......
...@@ -29,11 +29,22 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do ...@@ -29,11 +29,22 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do
end end
context 'when expression grammar is correct' do context 'when expression grammar is correct' do
let(:text) { '$VAR == "value"' } context 'when using an operator' do
let(:text) { '$VAR == "value"' }
it 'returns a reverse descent parse tree when using operator' do it 'returns a reverse descent parse tree' do
expect(subject.parse_tree) expect(subject.parse_tree)
.to be_a Gitlab::Ci::Pipeline::Expression::Equals .to be_a Gitlab::Ci::Pipeline::Expression::Equals
end
end
context 'when using a single token' do
let(:text) { '$VARIABLE' }
it 'returns a single token instance' do
expect(subject.parse_tree)
.to be_a Gitlab::Ci::Pipeline::Expression::Variable
end
end end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment