Commit 0df7a32e authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix tests

parent 2b907f61
......@@ -196,7 +196,7 @@ module Ci
rescue Psych::SyntaxError => e
save_yaml_error(e.message)
nil
rescue Exception => e
rescue Exception
save_yaml_error("Undefined yaml error")
nil
end
......
......@@ -53,7 +53,7 @@ module Ci
end
end
it 'fails commits without .gitlab-ci.yml' do
it 'skips commits without .gitlab-ci.yml' do
stub_ci_commit_yaml_file(nil)
result = service.execute(project, user,
ref: 'refs/heads/0_1',
......@@ -63,7 +63,24 @@ module Ci
)
expect(result).to be_persisted
expect(result.builds.any?).to be_falsey
expect(result.status).to eq('failed')
expect(result.status).to eq('skipped')
expect(commit.yaml_errors).to_not be_nil
end
it 'skips commits if yaml is invalid' do
message = 'message'
allow_any_instance_of(Ci::Commit).to receive(:git_commit_message) { message }
stub_ci_commit_yaml_file('invalid: file: file')
commits = [{ message: message }]
commit = service.execute(project, user,
ref: 'refs/tags/0_1',
before: '00000000',
after: '31das312',
commits: commits
)
expect(commit.builds.any?).to be false
expect(commit.status).to eq('skipped')
expect(commit.yaml_errors).to_not be_nil
end
describe :ci_skip? do
......@@ -114,23 +131,6 @@ module Ci
end
end
describe :config_processor do
it "skips builds creation if yaml is invalid" do
allow_any_instance_of(Ci::Commit).to receive(:git_commit_message) { "message" }
stub_ci_commit_yaml_file('invalid: file: file')
commits = [{ message: message }]
commit = service.execute(project, user,
ref: 'refs/tags/0_1',
before: '00000000',
after: '31das312',
commits: commits
)
expect(commit.builds.any?).to be false
expect(commit.status).to eq("skipped")
expect(commit.yaml_errors).to_not be_nil
end
end
it "skips build creation if there are already builds" do
allow_any_instance_of(Ci::Commit).to receive(:ci_yaml_file) { gitlab_ci_yaml }
......
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