Commit 75280a92 authored by John Skarbek's avatar John Skarbek

fixes a few rspecs...

parent 2134ff22
Pipeline #65065 failed with stages
in 23 seconds
......@@ -2,7 +2,7 @@ FROM google/cloud-sdk:245.0.0-alpine
ENV PROMETHEUS_VERSION 2.10.0
RUN apk add --no-cache tar ruby ruby-dev && \
RUN apk add --no-cache tar gcc libc-dev make ruby ruby-dev && \
wget -O prometheus.tar.gz https://github.com/prometheus/prometheus/releases/download/v$PROMETHEUS_VERSION/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz && \
mkdir /prometheus && \
tar -xvf prometheus.tar.gz -C /prometheus --strip-components 1 --wildcards */promtool && \
......
......@@ -49,41 +49,46 @@ describe 'create_kubernetes_rules' do
end
it 'validates yaml' do
rendered_template = '{}'
allow(YAML).to receive(:load_file).and_return(rendered_template)
result = yaml_valid?(rendered_template)
file = 'valid-yaml'
expect(YAML).to receive(:load_file).with(file).and_return(true)
result = yaml_valid?(file)
expect(result).to eq(true)
end
it 'reports invalid yaml' do
rendered_template = '{'
allow(YAML).to receive(:load_file).and_return(rendered_template)
result = yaml_valid?(rendered_template)
file = 'invalid-yaml'
expect(YAML).to receive(:load_file).with(file).and_raise(
StandardError.new('error')
)
result = yaml_valid?(file)
expect(result).to eq(false)
end
it 'validates rules' do
rendered_template = '{spec: {groups: [rules: [foo: ""]]}}'
allow(YAML).to receive(:load_file).and_return(rendered_template)
result = rules_valid?(rendered_template)
file = 'valid-rules'
expect(YAML).to receive(:load_file).with(file).and_return(true)
result = rules_valid?(file)
expect(result).to eq(true)
end
it 'reports invalid rules' do
file = 'invalid-rules'
rendered_template = '{spec: {groups: [rules: [foo: {}]]}}'
allow(YAML).to receive(:load_file).and_return(rendered_template)
result = rules_valid?(rendered_template)
expect(YAML).to receive(:load_file).with(file).and_return(rendered_template)
result = rules_valid?(file)
expect(result).to eq(false)
end
it 'skip known objects that are not strings' do
file = 'string-skip'
rendered_template = '{spec: {groups: [rules: [labels: {}, annotations: {}]]}}'
allow(YAML).to receive(:load_file).and_return(rendered_template)
result = rules_valid?(rendered_template)
expect(YAML).to receive(:load_file).with(file).and_return(rendered_template)
result = rules_valid?(file)
expect(result).to eq(true)
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