mortar 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mortar/command/generate.rb +2 -4
- data/lib/mortar/command/jobs.rb +14 -3
- data/lib/mortar/command/projects.rb +62 -9
- data/lib/mortar/git.rb +12 -4
- data/lib/mortar/version.rb +1 -1
- data/spec/mortar/command/generate_spec.rb +1 -28
- data/spec/mortar/command/jobs_spec.rb +56 -0
- data/spec/mortar/command/projects_spec.rb +125 -16
- metadata +8 -8
@@ -31,16 +31,14 @@ class Mortar::Command::Generate < Mortar::Command::Base
|
|
31
31
|
def _project
|
32
32
|
project_name = shift_argument
|
33
33
|
unless project_name
|
34
|
-
error("Usage: mortar
|
34
|
+
error("Usage: mortar generate:project PROJECTNAME\nMust specify PROJECTNAME.")
|
35
35
|
end
|
36
36
|
pigscript_name = project_name
|
37
37
|
app_generator = Mortar::Generators::ProjectGenerator.new
|
38
38
|
app_generator.generate_project(project_name, options)
|
39
39
|
end
|
40
|
-
alias_command "new", "generate:_project"
|
41
40
|
alias_command "generate:project", "generate:_project"
|
42
|
-
|
43
|
-
|
41
|
+
|
44
42
|
# generate:python_udf [UDFNAME]
|
45
43
|
#
|
46
44
|
# Generate a new python user defined function
|
data/lib/mortar/command/jobs.rb
CHANGED
@@ -67,7 +67,6 @@ class Mortar::Command::Jobs < Mortar::Command::Base
|
|
67
67
|
# Run the generate_regression_model_coefficients script on a 3 node cluster.
|
68
68
|
# $ mortar jobs:run generate_regression_model_coefficients --clustersize 3
|
69
69
|
def run
|
70
|
-
# arguemnts
|
71
70
|
pigscript_name = shift_argument
|
72
71
|
unless pigscript_name
|
73
72
|
error("Usage: mortar jobs:run PIGSCRIPT\nMust specify PIGSCRIPT.")
|
@@ -75,8 +74,20 @@ class Mortar::Command::Jobs < Mortar::Command::Base
|
|
75
74
|
validate_arguments!
|
76
75
|
|
77
76
|
unless options[:clusterid] || options[:clustersize]
|
78
|
-
|
79
|
-
|
77
|
+
clusters = api.get_clusters().body['clusters']
|
78
|
+
|
79
|
+
largest_free_cluster = clusters.select{ |c| \
|
80
|
+
c['running_job_ids'].length == 0 && c['status_code'] == Mortar::API::Clusters::STATUS_RUNNING }.
|
81
|
+
max_by{|c| c['size']}
|
82
|
+
|
83
|
+
if largest_free_cluster.nil?
|
84
|
+
options[:clustersize] = 2
|
85
|
+
display("Defaulting to running job on new cluster of size 2")
|
86
|
+
else
|
87
|
+
options[:clusterid] = largest_free_cluster['cluster_id']
|
88
|
+
display("Defaulting to running job on largest existing free cluster, id = " +
|
89
|
+
largest_free_cluster['cluster_id'] + ", size = " + largest_free_cluster['size'].to_s)
|
90
|
+
end
|
80
91
|
end
|
81
92
|
|
82
93
|
if options[:clusterid]
|
@@ -14,9 +14,13 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require "fileutils"
|
18
|
+
|
19
|
+
require "mortar/command"
|
17
20
|
require "mortar/command/base"
|
21
|
+
require "mortar/git"
|
18
22
|
|
19
|
-
# manage projects (create, clone)
|
23
|
+
# manage projects (create, register, clone, delete, set_remote)
|
20
24
|
#
|
21
25
|
class Mortar::Command::Projects < Mortar::Command::Base
|
22
26
|
|
@@ -34,30 +38,78 @@ class Mortar::Command::Projects < Mortar::Command::Base
|
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
37
|
-
# projects:
|
41
|
+
# projects:delete PROJECTNAME
|
42
|
+
#
|
43
|
+
# Delete a mortar project
|
44
|
+
def delete
|
45
|
+
name = shift_argument
|
46
|
+
unless name
|
47
|
+
error("Usage: mortar projects:delete PROJECTNAME\nMust specify PROJECTNAME.")
|
48
|
+
end
|
49
|
+
validate_arguments!
|
50
|
+
|
51
|
+
project_id = nil
|
52
|
+
action("Sending request to delete project: #{name}") do
|
53
|
+
api.delete_project(name).body["project_id"]
|
54
|
+
end
|
55
|
+
display "\nYour project has been deleted."
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# projects:create PROJECTNAME
|
38
60
|
#
|
39
|
-
#
|
61
|
+
# Generate and register a new Mortar project for code in the current directory, with the name PROJECTNAME.
|
40
62
|
def create
|
41
63
|
name = shift_argument
|
42
64
|
unless name
|
43
|
-
error("Usage: mortar projects:create
|
65
|
+
error("Usage: mortar projects:create PROJECTNAME\nMust specify PROJECTNAME")
|
66
|
+
end
|
67
|
+
|
68
|
+
Mortar::Command::run("generate:project", [name])
|
69
|
+
FileUtils.cd(name)
|
70
|
+
git.git_init
|
71
|
+
git.git("add .")
|
72
|
+
git.git("commit -m \"Mortar project scaffolding\"")
|
73
|
+
Mortar::Command::run("projects:register", [name])
|
74
|
+
git.git("push mortar master")
|
75
|
+
end
|
76
|
+
alias_command "new", "projects:create"
|
77
|
+
|
78
|
+
# projects:register PROJECT
|
79
|
+
#
|
80
|
+
# register a mortar project for the current directory with the name PROJECT
|
81
|
+
def register
|
82
|
+
name = shift_argument
|
83
|
+
unless name
|
84
|
+
error("Usage: mortar projects:register PROJECT\nMust specify PROJECT.")
|
44
85
|
end
|
45
86
|
validate_arguments!
|
46
87
|
|
47
88
|
unless git.has_dot_git?
|
48
|
-
|
89
|
+
# check if we're in the parent directory
|
90
|
+
if File.exists? name
|
91
|
+
error("mortar projects:register must be run from within the project directory.\nPlease \"cd #{name}\" and rerun this command.")
|
92
|
+
else
|
93
|
+
error("No git repository found in the current directory.\nPlease initialize a git repository for this project, and then rerun the register command.\nTo initialize your project in git, use:\n\ngit init\ngit add .\ngit commit -a -m \"first commit\"")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# ensure the project name does not already exist
|
98
|
+
project_names = api.get_projects().body["projects"].collect{|p| p['name']}
|
99
|
+
if project_names.include? name
|
100
|
+
error("Your account already contains a project named #{name}.\nPlease choose a different name for your new project, or clone the existing #{name} code using:\n\nmortar projects:clone #{name}")
|
49
101
|
end
|
50
102
|
|
51
103
|
unless git.remotes(git_organization).empty?
|
52
104
|
begin
|
53
|
-
error("Currently in project: #{project.name}. You can not
|
105
|
+
error("Currently in project: #{project.name}. You can not register a new project inside of an existing mortar project.")
|
54
106
|
rescue Mortar::Command::CommandFailed => cf
|
55
|
-
error("Currently in an existing Mortar project. You can not
|
107
|
+
error("Currently in an existing Mortar project. You can not register a new project inside of an existing mortar project.")
|
56
108
|
end
|
57
109
|
end
|
58
110
|
|
59
111
|
project_id = nil
|
60
|
-
action("Sending request to
|
112
|
+
action("Sending request to register project: #{name}") do
|
61
113
|
project_id = api.post_project(name).body["project_id"]
|
62
114
|
end
|
63
115
|
|
@@ -82,7 +134,7 @@ class Mortar::Command::Projects < Mortar::Command::Base
|
|
82
134
|
|
83
135
|
case project_status
|
84
136
|
when Mortar::API::Projects::STATUS_FAILED
|
85
|
-
error("Project
|
137
|
+
error("Project registration failed.\nError message: #{project_result['error_message']}")
|
86
138
|
when Mortar::API::Projects::STATUS_ACTIVE
|
87
139
|
git.remote_add("mortar", project_result['git_url'])
|
88
140
|
display "Your project is ready for use. Type 'mortar help' to see the commands you can perform on the project.\n\n"
|
@@ -91,6 +143,7 @@ class Mortar::Command::Projects < Mortar::Command::Base
|
|
91
143
|
end
|
92
144
|
|
93
145
|
end
|
146
|
+
alias_command "register", "projects:register"
|
94
147
|
|
95
148
|
# projects:set_remote PROJECT
|
96
149
|
#
|
data/lib/mortar/git.rb
CHANGED
@@ -41,6 +41,12 @@ module Mortar
|
|
41
41
|
end
|
42
42
|
has_git && is_ok_version
|
43
43
|
end
|
44
|
+
|
45
|
+
def ensure_has_git
|
46
|
+
unless has_git?
|
47
|
+
raise GitError, "git 1.7.7 or higher must be installed"
|
48
|
+
end
|
49
|
+
end
|
44
50
|
|
45
51
|
def run_cmd(cmd)
|
46
52
|
begin
|
@@ -54,12 +60,14 @@ module Mortar
|
|
54
60
|
def has_dot_git?
|
55
61
|
File.directory?(".git")
|
56
62
|
end
|
63
|
+
|
64
|
+
def git_init
|
65
|
+
ensure_has_git
|
66
|
+
run_cmd("git init")
|
67
|
+
end
|
57
68
|
|
58
69
|
def git(args, check_success=true, check_git_directory=true)
|
59
|
-
|
60
|
-
raise GitError, "git 1.7.7 or higher must be installed"
|
61
|
-
end
|
62
|
-
|
70
|
+
ensure_has_git
|
63
71
|
if check_git_directory && !has_dot_git?
|
64
72
|
raise GitError, "No .git directory found"
|
65
73
|
end
|
data/lib/mortar/version.rb
CHANGED
@@ -48,7 +48,7 @@ describe Mortar::Command::Generate do
|
|
48
48
|
it "error when name isn't provided" do
|
49
49
|
stderr, stdout = execute("generate:project")
|
50
50
|
stderr.should == <<-STDERR
|
51
|
-
! Usage: mortar
|
51
|
+
! Usage: mortar generate:project PROJECTNAME
|
52
52
|
! Must specify PROJECTNAME.
|
53
53
|
STDERR
|
54
54
|
end
|
@@ -79,33 +79,6 @@ STDERR
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
describe "new" do
|
83
|
-
it "create new project using alias" do
|
84
|
-
stderr, stdout = execute("new Test")
|
85
|
-
File.exists?("Test").should be_true
|
86
|
-
File.exists?("Test/macros").should be_true
|
87
|
-
File.exists?("Test/fixtures").should be_true
|
88
|
-
File.exists?("Test/pigscripts").should be_true
|
89
|
-
File.exists?("Test/udfs").should be_true
|
90
|
-
File.exists?("Test/README.md").should be_true
|
91
|
-
File.exists?("Test/Gemfile").should be_false
|
92
|
-
File.exists?("Test/macros/.gitkeep").should be_true
|
93
|
-
File.exists?("Test/fixtures/.gitkeep").should be_true
|
94
|
-
File.exists?("Test/pigscripts/Test.pig").should be_true
|
95
|
-
File.exists?("Test/udfs/python/Test.py").should be_true
|
96
|
-
|
97
|
-
File.read("Test/pigscripts/Test.pig").each_line { |line| line.match(/<%.*%>/).should be_nil }
|
98
|
-
end
|
99
|
-
|
100
|
-
it "error when name isn't provided" do
|
101
|
-
stderr, stdout = execute("new")
|
102
|
-
stderr.should == <<-STDERR
|
103
|
-
! Usage: mortar new PROJECTNAME
|
104
|
-
! Must specify PROJECTNAME.
|
105
|
-
STDERR
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
82
|
describe "generate:pigscript" do
|
110
83
|
it "Generate a new pigscript in a project" do
|
111
84
|
with_blank_project do |p|
|
@@ -109,6 +109,7 @@ STDOUT
|
|
109
109
|
job_url = "http://127.0.0.1:5000/jobs/job_detail?job_id=c571a8c7f76a4fd4a67c103d753e2dd5"
|
110
110
|
cluster_size = 2
|
111
111
|
|
112
|
+
mock(Mortar::Auth.api).get_clusters() {Excon::Response.new(:body => {'clusters' => []})}
|
112
113
|
mock(Mortar::Auth.api).post_job_new_cluster("myproject", "my_script", is_a(String), cluster_size,
|
113
114
|
:parameters => [],
|
114
115
|
:keepalive => true,
|
@@ -165,6 +166,61 @@ STDOUT
|
|
165
166
|
end
|
166
167
|
end
|
167
168
|
|
169
|
+
it "runs a job by default on the largest existing running cluster" do
|
170
|
+
with_git_initialized_project do |p|
|
171
|
+
job_id = "c571a8c7f76a4fd4a67c103d753e2dd5"
|
172
|
+
job_url = "http://127.0.0.1:5000/jobs/job_detail?job_id=c571a8c7f76a4fd4a67c103d753e2dd5"
|
173
|
+
|
174
|
+
small_cluster_id = '510beb6b3004860820ab6538'
|
175
|
+
small_cluster_size = 2
|
176
|
+
small_cluster_status = Mortar::API::Clusters::STATUS_RUNNING
|
177
|
+
large_cluster_id = '510bf0db3004860820ab6590'
|
178
|
+
large_cluster_size = 5
|
179
|
+
large_cluster_status = Mortar::API::Clusters::STATUS_RUNNING
|
180
|
+
starting_cluster_id = '510bf0db3004860820abaaaa'
|
181
|
+
starting_cluster_size = 10
|
182
|
+
starting_cluster_status = Mortar::API::Clusters::STATUS_STARTING
|
183
|
+
huge_busy_cluster_id = '510bf0db3004860820ab6621'
|
184
|
+
huge_busy_cluster_size = 20
|
185
|
+
huge_busy_cluster_status = Mortar::API::Clusters::STATUS_RUNNING
|
186
|
+
|
187
|
+
|
188
|
+
mock(Mortar::Auth.api).get_clusters() {
|
189
|
+
Excon::Response.new(:body => {
|
190
|
+
'clusters' => [
|
191
|
+
{ 'cluster_id' => small_cluster_id, 'size' => small_cluster_size, 'running_job_ids' => [], 'status_code' => small_cluster_status },
|
192
|
+
{ 'cluster_id' => large_cluster_id, 'size' => large_cluster_size, 'running_job_ids' => [], 'status_code' => large_cluster_status },
|
193
|
+
{ 'cluster_id' => starting_cluster_id, 'size' => starting_cluster_size, 'running_job_ids' => [], 'status_code' => starting_cluster_status },
|
194
|
+
{ 'cluster_id' => huge_busy_cluster_id, 'size' => huge_busy_cluster_size,
|
195
|
+
'running_job_ids' => ['c571a8c7f76a4fd4a67c103d753e2ee6'], 'status_code' => huge_busy_cluster_status }
|
196
|
+
]})
|
197
|
+
}
|
198
|
+
mock(Mortar::Auth.api).post_job_existing_cluster("myproject", "my_script", is_a(String), large_cluster_id,
|
199
|
+
:parameters => [],
|
200
|
+
:notify_on_job_finish => true) {Excon::Response.new(:body => {"job_id" => job_id, "web_job_url" => job_url})}
|
201
|
+
|
202
|
+
write_file(File.join(p.pigscripts_path, "my_script.pig"))
|
203
|
+
stderr, stdout = execute("jobs:run my_script ", p, @git)
|
204
|
+
stdout.should == <<-STDOUT
|
205
|
+
Defaulting to running job on largest existing free cluster, id = 510bf0db3004860820ab6590, size = 5
|
206
|
+
Taking code snapshot... done
|
207
|
+
Sending code snapshot to Mortar... done
|
208
|
+
Requesting job execution... done
|
209
|
+
job_id: c571a8c7f76a4fd4a67c103d753e2dd5
|
210
|
+
|
211
|
+
Job status can be viewed on the web at:
|
212
|
+
|
213
|
+
http://127.0.0.1:5000/jobs/job_detail?job_id=c571a8c7f76a4fd4a67c103d753e2dd5
|
214
|
+
|
215
|
+
Or by running:
|
216
|
+
|
217
|
+
mortar jobs:status c571a8c7f76a4fd4a67c103d753e2dd5 --poll
|
218
|
+
|
219
|
+
STDOUT
|
220
|
+
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
168
224
|
it "runs a job with parameter file" do
|
169
225
|
with_git_initialized_project do |p|
|
170
226
|
job_id = "c571a8c7f76a4fd4a67c103d753e2dd5"
|
@@ -28,6 +28,11 @@ module Mortar::Command
|
|
28
28
|
stub_core
|
29
29
|
@git = Mortar::Git::Git.new
|
30
30
|
end
|
31
|
+
|
32
|
+
before("create") do
|
33
|
+
@tmpdir = Dir.mktmpdir
|
34
|
+
Dir.chdir(@tmpdir)
|
35
|
+
end
|
31
36
|
|
32
37
|
project1 = {'name' => "Project1",
|
33
38
|
'status' => Mortar::API::Projects::STATUS_ACTIVE,
|
@@ -60,41 +65,144 @@ STDOUT
|
|
60
65
|
end
|
61
66
|
end
|
62
67
|
|
68
|
+
context("delete") do
|
69
|
+
it "shows error message when user doesn't include project name" do
|
70
|
+
stderr, stdout = execute("projects:delete")
|
71
|
+
stderr.should == <<-STDERR
|
72
|
+
! Usage: mortar projects:delete PROJECTNAME
|
73
|
+
! Must specify PROJECTNAME.
|
74
|
+
STDERR
|
75
|
+
end
|
76
|
+
|
77
|
+
it "deletes project" do
|
78
|
+
project_name = "COMMANDO"
|
79
|
+
|
80
|
+
mock(Mortar::Auth.api).delete_project(project_name).returns(Excon::Response.new(:body => {}, :status => 200 ))
|
81
|
+
stderr, stdout = execute("projects:delete COMMANDO")
|
82
|
+
stdout.should == <<-STDOUT
|
83
|
+
Sending request to delete project: COMMANDO... done
|
84
|
+
|
85
|
+
Your project has been deleted.
|
86
|
+
STDOUT
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
63
91
|
context("create") do
|
92
|
+
|
93
|
+
it "generates and registers a project" do
|
94
|
+
mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
|
95
|
+
project_id = "1234abcd1234abcd1234"
|
96
|
+
project_name = "some_new_project"
|
97
|
+
project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
|
98
|
+
mock(Mortar::Auth.api).post_project("some_new_project") {Excon::Response.new(:body => {"project_id" => project_id})}
|
99
|
+
mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_ACTIVE,
|
100
|
+
"git_url" => project_git_url})).ordered
|
101
|
+
mock(@git).remotes.with_any_args.returns({})
|
102
|
+
mock(@git).remote_add("mortar", project_git_url)
|
103
|
+
|
104
|
+
# if the git stuff doesn't work, the registration will fail, so we can pretend it does work here
|
105
|
+
mock(@git).git("add .").returns(true)
|
106
|
+
mock(@git).git("commit -m \"Mortar project scaffolding\"").returns(true)
|
107
|
+
mock(@git).git("push mortar master").returns(true)
|
108
|
+
|
109
|
+
stderr, stdout = execute("projects:create #{project_name}", nil, @git)
|
110
|
+
Dir.pwd.end_with?("some_new_project").should be_true
|
111
|
+
File.exists?("macros").should be_true
|
112
|
+
File.exists?("fixtures").should be_true
|
113
|
+
File.exists?("pigscripts").should be_true
|
114
|
+
File.exists?("udfs").should be_true
|
115
|
+
File.exists?("README.md").should be_true
|
116
|
+
File.exists?("Gemfile").should be_false
|
117
|
+
File.exists?("macros/.gitkeep").should be_true
|
118
|
+
File.exists?("fixtures/.gitkeep").should be_true
|
119
|
+
File.exists?("pigscripts/some_new_project.pig").should be_true
|
120
|
+
File.exists?("udfs/python/some_new_project.py").should be_true
|
121
|
+
|
122
|
+
File.read("pigscripts/some_new_project.pig").each_line { |line| line.match(/<%.*%>/).should be_nil }
|
123
|
+
|
124
|
+
stdout.should == <<-STDOUT
|
125
|
+
\e[1;32m create\e[0m
|
126
|
+
\e[1;32m create\e[0m README.md
|
127
|
+
\e[1;32m create\e[0m .gitignore
|
128
|
+
\e[1;32m create\e[0m pigscripts
|
129
|
+
\e[1;32m create\e[0m pigscripts/some_new_project.pig
|
130
|
+
\e[1;32m create\e[0m macros
|
131
|
+
\e[1;32m create\e[0m macros/.gitkeep
|
132
|
+
\e[1;32m create\e[0m fixtures
|
133
|
+
\e[1;32m create\e[0m fixtures/.gitkeep
|
134
|
+
\e[1;32m create\e[0m udfs
|
135
|
+
\e[1;32m create\e[0m udfs/python
|
136
|
+
\e[1;32m create\e[0m udfs/python/some_new_project.py
|
137
|
+
Sending request to register project: some_new_project... done\n\n\r\e[0KStatus: ACTIVE \n\nYour project is ready for use. Type 'mortar help' to see the commands you can perform on the project.\n
|
138
|
+
STDOUT
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
context("register") do
|
64
144
|
|
65
145
|
it "show appropriate error message when user doesn't include project name" do
|
66
|
-
stderr, stdout = execute("projects:
|
146
|
+
stderr, stdout = execute("projects:register")
|
67
147
|
stderr.should == <<-STDERR
|
68
|
-
! Usage: mortar projects:
|
148
|
+
! Usage: mortar projects:register PROJECT
|
69
149
|
! Must specify PROJECT.
|
70
150
|
STDERR
|
71
151
|
end
|
72
152
|
|
73
|
-
it "
|
153
|
+
it "tells you to cd to the directory if one exists with the project name" do
|
74
154
|
with_no_git_directory do
|
75
|
-
|
155
|
+
# create the project, but a level down from current directory
|
156
|
+
project_name = "existing_project_one_level_down"
|
157
|
+
FileUtils.mkdir_p(File.join(Dir.pwd, project_name))
|
158
|
+
stderr, stdout = execute("projects:register #{project_name}")
|
76
159
|
stderr.should == <<-STDERR
|
77
|
-
!
|
160
|
+
! mortar projects:register must be run from within the project directory.
|
161
|
+
! Please "cd existing_project_one_level_down" and rerun this command.
|
162
|
+
STDERR
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
it "tells you to create the git project in directory that doesn't have a git repository" do
|
167
|
+
with_no_git_directory do
|
168
|
+
stderr, stdout = execute("projects:register some_new_project")
|
169
|
+
stderr.should == <<-STDERR
|
170
|
+
! No git repository found in the current directory.
|
171
|
+
! Please initialize a git repository for this project, and then rerun the register command.
|
172
|
+
! To initialize your project in git, use:
|
78
173
|
!
|
79
174
|
! git init
|
80
175
|
! git add .
|
81
176
|
! git commit -a -m "first commit"
|
177
|
+
STDERR
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it "errors when a project already exists with the name requested" do
|
182
|
+
mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
|
183
|
+
with_git_initialized_project do |p|
|
184
|
+
stderr, stdout = execute("projects:register Project1", nil, @git)
|
185
|
+
stderr.should == <<-STDERR
|
186
|
+
! Your account already contains a project named Project1.
|
187
|
+
! Please choose a different name for your new project, or clone the existing Project1 code using:
|
82
188
|
!
|
83
|
-
!
|
189
|
+
! mortar projects:clone Project1
|
84
190
|
STDERR
|
85
191
|
end
|
86
192
|
end
|
87
|
-
|
88
|
-
it "show appropriate error message when user tries to
|
193
|
+
|
194
|
+
it "show appropriate error message when user tries to register a project inside of an existing project" do
|
195
|
+
mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
|
89
196
|
with_git_initialized_project do |p|
|
90
|
-
stderr, stdout = execute("projects:
|
197
|
+
stderr, stdout = execute("projects:register some_new_project", nil, @git)
|
91
198
|
stderr.should == <<-STDERR
|
92
|
-
! Currently in project: myproject. You can not
|
199
|
+
! Currently in project: myproject. You can not register a new project inside of an existing mortar project.
|
93
200
|
STDERR
|
94
201
|
end
|
95
202
|
end
|
96
203
|
|
97
|
-
it "
|
204
|
+
it "register a new project successfully - with status" do
|
205
|
+
mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
|
98
206
|
project_id = "1234abcd1234abcd1234"
|
99
207
|
project_name = "some_new_project"
|
100
208
|
project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
|
@@ -108,13 +216,14 @@ STDERR
|
|
108
216
|
mock(@git).remotes.with_any_args.returns({})
|
109
217
|
mock(@git).remote_add("mortar", project_git_url)
|
110
218
|
|
111
|
-
stderr, stdout = execute("projects:
|
219
|
+
stderr, stdout = execute("projects:register #{project_name} --polling_interval 0.05", nil, @git)
|
112
220
|
stdout.should == <<-STDOUT
|
113
|
-
Sending request to
|
221
|
+
Sending request to register project: some_new_project... done\n\n\r\e[0KStatus: PENDING... /\r\e[0KStatus: CREATING... -\r\e[0KStatus: ACTIVE \n\nYour project is ready for use. Type 'mortar help' to see the commands you can perform on the project.\n
|
114
222
|
STDOUT
|
115
223
|
end
|
116
224
|
|
117
|
-
it "
|
225
|
+
it "register a new project successfully - with status_code and status_description" do
|
226
|
+
mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
|
118
227
|
project_id = "1234abcd1234abcd1234"
|
119
228
|
project_name = "some_new_project"
|
120
229
|
project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
|
@@ -128,9 +237,9 @@ STDOUT
|
|
128
237
|
mock(@git).remotes.with_any_args.returns({})
|
129
238
|
mock(@git).remote_add("mortar", project_git_url)
|
130
239
|
|
131
|
-
stderr, stdout = execute("projects:
|
240
|
+
stderr, stdout = execute("projects:register #{project_name} --polling_interval 0.05", nil, @git)
|
132
241
|
stdout.should == <<-STDOUT
|
133
|
-
Sending request to
|
242
|
+
Sending request to register project: some_new_project... done\n\n\r\e[0KStatus: Pending... /\r\e[0KStatus: Creating... -\r\e[0KStatus: Active \n\nYour project is ready for use. Type 'mortar help' to see the commands you can perform on the project.\n
|
134
243
|
STDOUT
|
135
244
|
end
|
136
245
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mortar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mortar Data
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-02-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: mortar-api-ruby
|
@@ -25,12 +25,12 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 9
|
29
29
|
segments:
|
30
30
|
- 0
|
31
31
|
- 5
|
32
|
-
-
|
33
|
-
version: 0.5.
|
32
|
+
- 1
|
33
|
+
version: 0.5.1
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|