summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-08-04 20:35:04 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-08-05 12:16:24 +0200
commit9cce83b1290826ad19acffb6e095a0e8b963c05f (patch)
tree5dc7ba1baff4b8029a8c0c3e5125b9c1fe48ffcb /spec
parent9d95dfe6018a6d039bc4f0d9ff42131b0ff9505c (diff)
downloadgitlab-ci-9cce83b1290826ad19acffb6e095a0e8b963c05f.tar.gz
Added support for YAML-defined variables
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab_ci_yaml_processor_spec.rb33
-rw-r--r--spec/requests/api/builds_spec.rb5
-rw-r--r--spec/support/gitlab_stubs/gitlab_ci.yml3
3 files changed, 39 insertions, 2 deletions
diff --git a/spec/lib/gitlab_ci_yaml_processor_spec.rb b/spec/lib/gitlab_ci_yaml_processor_spec.rb
index fdd77ed..5b9a4f1 100644
--- a/spec/lib/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/gitlab_ci_yaml_processor_spec.rb
@@ -153,6 +153,23 @@ describe GitlabCiYamlProcessor do
end
end
+ describe "Variables" do
+ it "returns variables when defined" do
+ variables = {
+ var1: "value1",
+ var2: "value2",
+ }
+ config = YAML.dump({
+ variables: variables,
+ before_script: ["pwd"],
+ rspec: {script: "rspec"}
+ })
+
+ config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor.variables.should == variables
+ end
+ end
+
describe "Error handling" do
it "indicates that object is invalid" do
expect{GitlabCiYamlProcessor.new("invalid_yaml\n!ccdvlf%612334@@@@")}.to raise_error(GitlabCiYamlProcessor::ValidationError)
@@ -269,5 +286,19 @@ describe GitlabCiYamlProcessor do
GitlabCiYamlProcessor.new(config)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "stages should be an array of strings")
end
+
+ it "returns errors if variables is not a map" do
+ config = YAML.dump({variables: "test", rspec: {script: "test"}})
+ expect do
+ GitlabCiYamlProcessor.new(config)
+ end.to raise_error(GitlabCiYamlProcessor::ValidationError, "variables should be a map of key-valued strings")
+ end
+
+ it "returns errors if variables is not a map of key-valued strings" do
+ config = YAML.dump({variables: {test: false}, rspec: {script: "test"}})
+ expect do
+ GitlabCiYamlProcessor.new(config)
+ end.to raise_error(GitlabCiYamlProcessor::ValidationError, "variables should be a map of key-valued strings")
+ end
end
-end \ No newline at end of file
+end
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index b44798b..a169f8e 100644
--- a/spec/requests/api/builds_spec.rb
+++ b/spec/requests/api/builds_spec.rb
@@ -69,7 +69,10 @@ describe API::API do
post api("/builds/register"), token: runner.token, info: {platform: :darwin}
response.status.should == 201
- json_response["variables"].should == [{"key" => "SECRET_KEY", "value" => "secret_value"}]
+ json_response["variables"].should == [
+ {"key" => "DB_NAME", "value" => "postgres", "public" => true},
+ {"key" => "SECRET_KEY", "value" => "secret_value", "public" => false},
+ ]
end
end
diff --git a/spec/support/gitlab_stubs/gitlab_ci.yml b/spec/support/gitlab_stubs/gitlab_ci.yml
index 8533cdb..3482145 100644
--- a/spec/support/gitlab_stubs/gitlab_ci.yml
+++ b/spec/support/gitlab_stubs/gitlab_ci.yml
@@ -7,6 +7,9 @@ before_script:
- bundle install
- bundle exec rake db:create
+variables:
+ DB_NAME: postgres
+
types:
- test
- deploy