ey_resolver 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ey_resolver/examiner.rb +30 -9
- data/lib/ey_resolver/version.rb +1 -1
- data/spec/account_resolver_spec.rb +18 -14
- data/spec/app_env_resolver_spec.rb +61 -25
- data/spec/app_resolver_spec.rb +0 -8
- data/spec/environment_resolver_spec.rb +56 -22
- data/spec/spec_helper.rb +32 -0
- metadata +10 -10
data/lib/ey_resolver/examiner.rb
CHANGED
@@ -10,8 +10,7 @@ class EY::Resolver
|
|
10
10
|
|
11
11
|
def initialize(query, user)
|
12
12
|
@query, @user = query, user
|
13
|
-
|
14
|
-
@suggestions ||= {}
|
13
|
+
@suggestions = []
|
15
14
|
end
|
16
15
|
|
17
16
|
def app_unconstrained_errors
|
@@ -70,12 +69,20 @@ class EY::Resolver
|
|
70
69
|
if query.app_constrained? && accounts.any? && apps.any? && acc_apps.empty?
|
71
70
|
app_names = apps.map {|a|a.name.inspect}.join(', ')
|
72
71
|
problems << "Application #{app_names} found, but does not exist in account #{account_name}."
|
73
|
-
|
72
|
+
apps.each do |app|
|
73
|
+
app.environments.each do |env|
|
74
|
+
add_suggestion(app, env)
|
75
|
+
end
|
76
|
+
end
|
74
77
|
end
|
75
78
|
|
76
79
|
if query.environment_name && accounts.any? && envs.any? && acc_envs.empty?
|
77
80
|
problems << "Environment #{environment_name} found, but does not exist in account #{account_name}."
|
78
|
-
|
81
|
+
envs.each do |env|
|
82
|
+
env.apps.each do |app|
|
83
|
+
add_suggestion(app, env)
|
84
|
+
end
|
85
|
+
end
|
79
86
|
end
|
80
87
|
return problems if problems.any?
|
81
88
|
end
|
@@ -85,7 +92,6 @@ class EY::Resolver
|
|
85
92
|
|
86
93
|
if !query.environment_name && query.remotes && acc_envs.empty? && acc_apps.any?
|
87
94
|
problems << "No environment found for applications matching remotes:" + query.remotes.map { |uri| "\n\t#{uri}" }.join
|
88
|
-
#@suggestions[:apps] = acc_apps
|
89
95
|
end
|
90
96
|
|
91
97
|
return problems if problems.any?
|
@@ -97,12 +103,23 @@ class EY::Resolver
|
|
97
103
|
|
98
104
|
if query.environment_name && query.app_name && acc_envs.any? && acc_apps.any?
|
99
105
|
problems << "Application #{app_name} and environment #{environment_name} are not associated."
|
100
|
-
|
101
|
-
|
106
|
+
acc_envs.each do |env|
|
107
|
+
env.apps.each do |app|
|
108
|
+
add_suggestion(app, env)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
acc_apps.each do |app|
|
112
|
+
app.environments.each do |env|
|
113
|
+
add_suggestion(app, env)
|
114
|
+
end
|
115
|
+
end
|
102
116
|
elsif query.remotes && acc_envs.any? && acc_apps.any?
|
103
117
|
problems << "Application #{acc_apps.map {|a|a.name.inspect}.join(', ')} and environment #{environment_name} are not associated."
|
104
|
-
|
105
|
-
|
118
|
+
acc_apps.each do |app|
|
119
|
+
app.environments.each do |env|
|
120
|
+
add_suggestion(app, env)
|
121
|
+
end
|
122
|
+
end
|
106
123
|
end
|
107
124
|
|
108
125
|
return problems if problems.any?
|
@@ -139,5 +156,9 @@ class EY::Resolver
|
|
139
156
|
def acc_envs
|
140
157
|
@acc_envs ||= EnvironmentResolver.new(@user, :environment_name => query.environment_name, :remotes => query.remotes, :account_name => query.account_name).matches
|
141
158
|
end
|
159
|
+
|
160
|
+
def add_suggestion(app, env)
|
161
|
+
@suggestions << {'account_name' => app.account.name, 'app_name' => app.name, 'environment_name' => env.name}
|
162
|
+
end
|
142
163
|
end
|
143
164
|
end
|
data/lib/ey_resolver/version.rb
CHANGED
@@ -2,14 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe EY::Resolver::AppEnvResolver do
|
4
4
|
|
5
|
-
def account_resolver(*args)
|
6
|
-
EY::Resolver.account_resolver(user, to_query(args))
|
7
|
-
end
|
8
|
-
|
9
|
-
def accounts(*models)
|
10
|
-
models.map { |model| model[:account] }
|
11
|
-
end
|
12
|
-
|
13
5
|
before(:all) do
|
14
6
|
# More correct names, even though it doesn't matter
|
15
7
|
@ey = @production
|
@@ -83,38 +75,50 @@ describe EY::Resolver::AppEnvResolver do
|
|
83
75
|
|
84
76
|
describe "#errors" do
|
85
77
|
it "no account" do
|
86
|
-
account_resolver('gibberish', 'app', 'production')
|
78
|
+
resolver = account_resolver('gibberish', 'app', 'production')
|
79
|
+
resolver.errors.should ==
|
87
80
|
[%|No account found matching "gibberish".|]
|
81
|
+
resolver.suggestions.should == []
|
88
82
|
end
|
89
83
|
|
90
84
|
it "no app" do
|
91
|
-
account_resolver(nil, 'gibberish', 'app_dup')
|
85
|
+
resolver = account_resolver(nil, 'gibberish', 'app_dup')
|
86
|
+
resolver.errors.should ==
|
92
87
|
[%|No application found matching "gibberish".|]
|
88
|
+
resolver.suggestions.should == []
|
93
89
|
end
|
94
90
|
|
95
91
|
it "no env" do
|
96
|
-
account_resolver('ey', 'app', 'gibberish')
|
92
|
+
resolver = account_resolver('ey', 'app', 'gibberish')
|
93
|
+
resolver.errors.should ==
|
97
94
|
[%|No environment found matching "gibberish".|]
|
95
|
+
resolver.suggestions.should == []
|
98
96
|
end
|
99
97
|
|
100
98
|
it "no account or app" do
|
101
|
-
account_resolver('gibberish', 'gibberish', nil)
|
99
|
+
resolver = account_resolver('gibberish', 'gibberish', nil)
|
100
|
+
resolver.errors.should == [
|
102
101
|
%|No account found matching "gibberish".|,
|
103
102
|
%|No application found matching "gibberish".|,
|
104
103
|
]
|
104
|
+
resolver.suggestions.should == []
|
105
105
|
end
|
106
106
|
|
107
107
|
it "no account or app or env" do
|
108
|
-
account_resolver('gibberish', 'gibberish', 'gibberish')
|
108
|
+
resolver = account_resolver('gibberish', 'gibberish', 'gibberish')
|
109
|
+
resolver.errors.should == [
|
109
110
|
%|No account found matching "gibberish".|,
|
110
111
|
%|No application found matching "gibberish".|,
|
111
112
|
%|No environment found matching "gibberish".|,
|
112
113
|
]
|
114
|
+
resolver.suggestions.should == []
|
113
115
|
end
|
114
116
|
|
115
117
|
it "repo not found" do
|
116
|
-
account_resolver(nil, nil, nil, ["git://fake.com/fake/fake.git"])
|
118
|
+
resolver = account_resolver(nil, nil, nil, ["git://fake.com/fake/fake.git"])
|
119
|
+
resolver.errors.should ==
|
117
120
|
[%|No application found matching remotes:\n\tgit://fake.com/fake/fake.git|]
|
121
|
+
resolver.suggestions.should == []
|
118
122
|
end
|
119
123
|
end
|
120
124
|
end
|
@@ -2,14 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe EY::Resolver::AppEnvResolver do
|
4
4
|
|
5
|
-
def app_env_resolver(*args)
|
6
|
-
EY::Resolver.app_env_resolver(user, to_query(args))
|
7
|
-
end
|
8
|
-
|
9
|
-
def app_envs(*models)
|
10
|
-
models.map { |model| model[:app_env] }
|
11
|
-
end
|
12
|
-
|
13
5
|
describe "#matches" do
|
14
6
|
it "raises if the conditions are empty" do
|
15
7
|
app_env_resolver( ).matches.should == []
|
@@ -80,80 +72,124 @@ describe EY::Resolver::AppEnvResolver do
|
|
80
72
|
end
|
81
73
|
end
|
82
74
|
|
83
|
-
describe "
|
84
|
-
|
75
|
+
describe "errors and suggestions" do
|
85
76
|
it "no constraints" do
|
86
|
-
app_env_resolver()
|
77
|
+
resolver = app_env_resolver()
|
78
|
+
resolver.errors.should ==
|
87
79
|
[%|Must search by account name, app name, remotes, or environment name.|]
|
80
|
+
resolver.suggestions.should be_empty
|
88
81
|
end
|
89
82
|
|
90
83
|
it "no app constraints" do
|
91
|
-
app_env_resolver('ey')
|
84
|
+
resolver = app_env_resolver('ey')
|
85
|
+
resolver.errors.should ==
|
92
86
|
[%|App name or repository remotes required.|]
|
87
|
+
resolver.suggestions.should be_empty
|
93
88
|
end
|
94
89
|
|
95
90
|
it "no account" do
|
96
|
-
app_env_resolver('gibberish', 'app', 'production')
|
91
|
+
resolver = app_env_resolver('gibberish', 'app', 'production')
|
92
|
+
resolver.errors.should ==
|
97
93
|
[%|No account found matching "gibberish".|]
|
94
|
+
resolver.suggestions.should be_empty
|
98
95
|
end
|
99
96
|
|
100
97
|
it "no app" do
|
101
|
-
app_env_resolver(nil, 'gibberish', 'app_dup')
|
98
|
+
resolver = app_env_resolver(nil, 'gibberish', 'app_dup')
|
99
|
+
resolver.errors.should ==
|
102
100
|
[%|No application found matching "gibberish".|]
|
101
|
+
resolver.suggestions.should be_empty
|
103
102
|
end
|
104
103
|
|
105
104
|
it "app found, but not on account" do
|
106
|
-
app_env_resolver('no', 'bigapp', 'app_dup')
|
105
|
+
resolver = app_env_resolver('no', 'bigapp', 'app_dup')
|
106
|
+
resolver.errors.should == [
|
107
107
|
%|Application "bigapp" found, but does not exist in account "no".|,
|
108
108
|
%|Environment "app_dup" found, but does not exist in account "no".|,
|
109
109
|
]
|
110
|
+
resolver.suggestions.should =~ [
|
111
|
+
{'account_name' => 'ey', 'app_name' => 'bigapp', 'environment_name' => 'bigapp_staging'},
|
112
|
+
{'account_name' => 'ey', 'app_name' => 'app_dup', 'environment_name' => 'app_dup'},
|
113
|
+
{'account_name' => 'me', 'app_name' => 'app_dup', 'environment_name' => 'app_dup'},
|
114
|
+
{'account_name' => 'me', 'app_name' => 'other', 'environment_name' => 'app_dup'}
|
115
|
+
]
|
110
116
|
end
|
111
117
|
|
112
118
|
it "no env" do
|
113
|
-
app_env_resolver('ey', 'app', 'gibberish')
|
119
|
+
resolver = app_env_resolver('ey', 'app', 'gibberish')
|
120
|
+
resolver.errors.should ==
|
114
121
|
[%|No environment found matching "gibberish".|]
|
122
|
+
resolver.suggestions.should be_empty
|
115
123
|
end
|
116
124
|
|
117
125
|
it "no env on account" do
|
118
|
-
app_env_resolver('me', 'other', 'production')
|
126
|
+
resolver = app_env_resolver('me', 'other', 'production')
|
127
|
+
resolver.errors.should ==
|
119
128
|
[%|Environment "production" found, but does not exist in account "me".|]
|
129
|
+
resolver.suggestions.should =~ [
|
130
|
+
{'account_name' => 'ey', 'app_name' => 'huge', 'environment_name' => 'production'}
|
131
|
+
]
|
120
132
|
end
|
121
133
|
|
122
134
|
it "no account or app" do
|
123
|
-
app_env_resolver('gibberish', 'gibberish', nil)
|
135
|
+
resolver = app_env_resolver('gibberish', 'gibberish', nil)
|
136
|
+
resolver.errors.should == [
|
124
137
|
%|No account found matching "gibberish".|,
|
125
138
|
%|No application found matching "gibberish".|,
|
126
139
|
]
|
140
|
+
resolver.suggestions.should be_empty
|
127
141
|
end
|
128
142
|
|
129
143
|
it "no account or app or env" do
|
130
|
-
app_env_resolver('gibberish', 'gibberish', 'gibberish')
|
144
|
+
resolver = app_env_resolver('gibberish', 'gibberish', 'gibberish')
|
145
|
+
resolver.errors.should == [
|
131
146
|
%|No account found matching "gibberish".|,
|
132
147
|
%|No application found matching "gibberish".|,
|
133
148
|
%|No environment found matching "gibberish".|,
|
134
149
|
]
|
150
|
+
resolver.suggestions.should be_empty
|
135
151
|
end
|
136
152
|
|
137
153
|
it "repo not found" do
|
138
|
-
app_env_resolver(nil, nil, nil, ["git://fake.com/fake/fake.git"])
|
154
|
+
resolver = app_env_resolver(nil, nil, nil, ["git://fake.com/fake/fake.git"])
|
155
|
+
resolver.errors.should ==
|
139
156
|
[%|No application found matching remotes:\n\tgit://fake.com/fake/fake.git|]
|
157
|
+
resolver.suggestions.should be_empty
|
140
158
|
end
|
141
159
|
|
142
160
|
it "repo not found in account" do
|
143
|
-
app_env_resolver('ey', nil, nil, ["git://github.com/repo/oth.git"])
|
161
|
+
resolver = app_env_resolver('ey', nil, nil, ["git://github.com/repo/oth.git"])
|
162
|
+
resolver.errors.should ==
|
144
163
|
[%|Application "other" found, but does not exist in account "ey".|]
|
164
|
+
resolver.suggestions.should =~
|
165
|
+
[{'account_name' => 'me', 'app_name' => 'other', 'environment_name' => 'app_dup'}]
|
145
166
|
end
|
146
167
|
|
147
168
|
it "app and environment not associated" do
|
148
|
-
app_env_resolver('ey', 'bigapp', '
|
149
|
-
|
150
|
-
|
169
|
+
resolver = app_env_resolver('ey', 'bigapp', 'app_staging')
|
170
|
+
resolver.errors.should ==
|
171
|
+
[%|Application "bigapp" and environment "app_staging" are not associated.|]
|
172
|
+
resolver.suggestions.should =~ [
|
173
|
+
{'account_name' => 'ey', 'app_name' => 'bigapp', 'environment_name' => 'bigapp_staging'},
|
174
|
+
{'account_name' => 'ey', 'app_name' => 'app', 'environment_name' => 'app_staging'}
|
175
|
+
]
|
176
|
+
end
|
177
|
+
|
178
|
+
it "another app and environment not associated" do
|
179
|
+
resolver = app_env_resolver(nil, nil, 'app_dup', ["git://github.com/repo/app.git"])
|
180
|
+
resolver.errors.should ==
|
151
181
|
[%|Application "app" and environment "app_dup" are not associated.|]
|
182
|
+
resolver.suggestions.should =~ [
|
183
|
+
{"account_name"=>"ey", 'app_name' => 'app', "environment_name"=>"app_production"},
|
184
|
+
{"account_name"=>"ey", 'app_name' => 'app', "environment_name"=>"app_staging"}
|
185
|
+
]
|
152
186
|
end
|
153
187
|
|
154
188
|
it "app (by repo) does not have an environment" do
|
155
|
-
app_env_resolver(nil, nil, nil, ["git://github.com/repo/noe.git"])
|
189
|
+
resolver = app_env_resolver(nil, nil, nil, ["git://github.com/repo/noe.git"])
|
190
|
+
resolver.errors.should ==
|
156
191
|
[%|No environment found for applications matching remotes:\n\tgit://github.com/repo/noe.git|]
|
192
|
+
resolver.suggestions.should be_empty
|
157
193
|
end
|
158
194
|
end
|
159
195
|
end
|
data/spec/app_resolver_spec.rb
CHANGED
@@ -2,14 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe EY::Resolver::AppEnvResolver do
|
4
4
|
|
5
|
-
def app_resolver(*args)
|
6
|
-
EY::Resolver.app_resolver(user, to_query(args))
|
7
|
-
end
|
8
|
-
|
9
|
-
def apps(*models)
|
10
|
-
models.map { |model| model[:app] }
|
11
|
-
end
|
12
|
-
|
13
5
|
describe "#matches" do
|
14
6
|
it "returns none if the conditions are empty" do
|
15
7
|
app_resolver( ).matches.should == []
|
@@ -2,14 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe EY::Resolver::EnvironmentResolver do
|
4
4
|
|
5
|
-
def env_resolver(*args)
|
6
|
-
EY::Resolver.environment_resolver(user, to_query(args))
|
7
|
-
end
|
8
|
-
|
9
|
-
def envs(*models)
|
10
|
-
models.map { |model| model[:env] }
|
11
|
-
end
|
12
|
-
|
13
5
|
describe "#matches" do
|
14
6
|
it "raises if the conditions are empty" do
|
15
7
|
env_resolver( ).matches.should == []
|
@@ -90,77 +82,119 @@ describe EY::Resolver::EnvironmentResolver do
|
|
90
82
|
end
|
91
83
|
end
|
92
84
|
|
93
|
-
describe "
|
85
|
+
describe "errors and suggestions" do
|
94
86
|
it "no account" do
|
95
|
-
env_resolver('gibberish', 'app', 'production')
|
87
|
+
resolver = env_resolver('gibberish', 'app', 'production')
|
88
|
+
resolver.errors.should ==
|
96
89
|
[%|No account found matching "gibberish".|]
|
90
|
+
resolver.suggestions.should be_empty
|
97
91
|
end
|
98
92
|
|
99
93
|
it "no app" do
|
100
|
-
env_resolver(nil, 'gibberish', 'app_dup')
|
94
|
+
resolver = env_resolver(nil, 'gibberish', 'app_dup')
|
95
|
+
resolver.errors.should ==
|
101
96
|
[%|No application found matching "gibberish".|]
|
97
|
+
resolver.suggestions.should be_empty
|
102
98
|
end
|
103
99
|
|
104
100
|
it "app found, but not on account" do
|
105
|
-
env_resolver('no', 'bigapp', 'app_dup')
|
101
|
+
resolver = env_resolver('no', 'bigapp', 'app_dup')
|
102
|
+
resolver.errors.should == [
|
106
103
|
%|Application "bigapp" found, but does not exist in account "no".|,
|
107
104
|
%|Environment "app_dup" found, but does not exist in account "no".|,
|
108
105
|
]
|
106
|
+
resolver.suggestions.should =~ [
|
107
|
+
{'account_name' => 'ey', 'app_name' => 'bigapp', 'environment_name' => 'bigapp_staging'},
|
108
|
+
{'account_name' => 'ey', 'app_name' => 'app_dup', 'environment_name' => 'app_dup'},
|
109
|
+
{'account_name' => 'me', 'app_name' => 'app_dup', 'environment_name' => 'app_dup'},
|
110
|
+
{'account_name' => 'me', 'app_name' => 'other', 'environment_name' => 'app_dup'}
|
111
|
+
]
|
109
112
|
end
|
110
113
|
|
111
114
|
it "no env" do
|
112
|
-
env_resolver('ey', nil, 'gibberish')
|
115
|
+
resolver = env_resolver('ey', nil, 'gibberish')
|
116
|
+
resolver.errors.should ==
|
113
117
|
[%|No environment found matching "gibberish".|]
|
118
|
+
resolver.suggestions.should be_empty
|
114
119
|
end
|
115
120
|
|
116
121
|
it "no env on account" do
|
117
|
-
env_resolver('no', nil, 'app_dup')
|
122
|
+
resolver = env_resolver('no', nil, 'app_dup')
|
123
|
+
resolver.errors.should ==
|
118
124
|
[%|Environment "app_dup" found, but does not exist in account "no".|]
|
125
|
+
resolver.suggestions.should =~ [
|
126
|
+
{'account_name' => 'ey', 'app_name' => 'app_dup', 'environment_name' => 'app_dup'},
|
127
|
+
{'account_name' => 'me', 'app_name' => 'app_dup', 'environment_name' => 'app_dup'},
|
128
|
+
{'account_name' => 'me', 'app_name' => 'other', 'environment_name' => 'app_dup'}
|
129
|
+
]
|
119
130
|
end
|
120
131
|
|
121
132
|
it "no account or app" do
|
122
|
-
env_resolver('gibberish', 'gibberish', nil)
|
133
|
+
resolver = env_resolver('gibberish', 'gibberish', nil)
|
134
|
+
resolver.errors.should == [
|
123
135
|
%|No account found matching "gibberish".|,
|
124
136
|
%|No application found matching "gibberish".|,
|
125
137
|
]
|
138
|
+
resolver.suggestions.should be_empty
|
126
139
|
end
|
127
140
|
|
128
141
|
it "no account or app or env" do
|
129
|
-
env_resolver('gibberish', 'gibberish', 'gibberish')
|
142
|
+
resolver = env_resolver('gibberish', 'gibberish', 'gibberish')
|
143
|
+
resolver.errors.should == [
|
130
144
|
%|No account found matching "gibberish".|,
|
131
145
|
%|No application found matching "gibberish".|,
|
132
146
|
%|No environment found matching "gibberish".|,
|
133
147
|
]
|
148
|
+
resolver.suggestions.should be_empty
|
134
149
|
end
|
135
150
|
|
136
151
|
it "repo not found" do
|
137
|
-
env_resolver(nil, nil, nil, ["git://fake.com/fake/fake.git"])
|
152
|
+
resolver = env_resolver(nil, nil, nil, ["git://fake.com/fake/fake.git"])
|
153
|
+
resolver.errors.should ==
|
138
154
|
[%|No application found matching remotes:\n\tgit://fake.com/fake/fake.git|]
|
155
|
+
resolver.suggestions.should be_empty
|
139
156
|
end
|
140
157
|
|
141
158
|
it "repo found but env doesn't exist on it" do
|
142
|
-
env_resolver(nil, nil, nil, ["git://github.com/repo/noe.git"])
|
159
|
+
resolver = env_resolver(nil, nil, nil, ["git://github.com/repo/noe.git"])
|
160
|
+
resolver.errors.should ==
|
143
161
|
[%|No environment found for applications matching remotes:\n\tgit://github.com/repo/noe.git|]
|
162
|
+
resolver.suggestions.should be_empty
|
144
163
|
end
|
145
164
|
|
146
165
|
it "repo not found in account" do
|
147
|
-
env_resolver('ey', nil, nil, ["git://github.com/repo/oth.git"])
|
166
|
+
resolver = env_resolver('ey', nil, nil, ["git://github.com/repo/oth.git"])
|
167
|
+
resolver.errors.should ==
|
148
168
|
[%|Application "other" found, but does not exist in account "ey".|]
|
169
|
+
resolver.suggestions.should =~
|
170
|
+
[{"account_name"=>"me", "app_name"=>"other", "environment_name"=>"app_dup"}]
|
149
171
|
end
|
150
172
|
|
151
173
|
it "app and environment not associated" do
|
152
|
-
env_resolver('ey', 'bigapp', 'app_dup')
|
174
|
+
resolver = env_resolver('ey', 'bigapp', 'app_dup')
|
175
|
+
resolver.errors.should ==
|
153
176
|
[%|Application "bigapp" and environment "app_dup" are not associated.|]
|
177
|
+
resolver.suggestions.should =~ [
|
178
|
+
{"account_name"=>"ey", "app_name"=>"app_dup", "environment_name"=>"app_dup"},
|
179
|
+
{"account_name"=>"ey", "app_name"=>"bigapp", "environment_name"=>"bigapp_staging"}
|
180
|
+
]
|
154
181
|
end
|
155
182
|
|
156
183
|
it "app (by repo) and environment not associated" do
|
157
|
-
env_resolver(nil, nil, 'app_dup', ["git://github.com/repo/app.git"])
|
184
|
+
resolver = env_resolver(nil, nil, 'app_dup', ["git://github.com/repo/app.git"])
|
185
|
+
resolver.errors.should ==
|
158
186
|
[%|Application "app" and environment "app_dup" are not associated.|]
|
187
|
+
resolver.suggestions.should =~ [
|
188
|
+
{"account_name"=>"ey", 'app_name' => 'app', "environment_name"=>"app_production"},
|
189
|
+
{"account_name"=>"ey", 'app_name' => 'app', "environment_name"=>"app_staging"}
|
190
|
+
]
|
159
191
|
end
|
160
192
|
|
161
193
|
it "app (by repo) does not have an environment" do
|
162
|
-
env_resolver(nil, nil, nil, ["git://github.com/repo/noe.git"])
|
194
|
+
resolver = env_resolver(nil, nil, nil, ["git://github.com/repo/noe.git"])
|
195
|
+
resolver.errors.should ==
|
163
196
|
[%|No environment found for applications matching remotes:\n\tgit://github.com/repo/noe.git|]
|
197
|
+
resolver.suggestions.should be_empty
|
164
198
|
end
|
165
199
|
end
|
166
200
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -63,6 +63,38 @@ module Helpers
|
|
63
63
|
def to_query(args)
|
64
64
|
Hash[%w[account_name app_name environment_name remotes].zip(args)]
|
65
65
|
end
|
66
|
+
|
67
|
+
def app_env_resolver(*args)
|
68
|
+
EY::Resolver.app_env_resolver(user, to_query(args))
|
69
|
+
end
|
70
|
+
|
71
|
+
def app_envs(*models)
|
72
|
+
models.map { |model| model[:app_env] }
|
73
|
+
end
|
74
|
+
|
75
|
+
def app_resolver(*args)
|
76
|
+
EY::Resolver.app_resolver(user, to_query(args))
|
77
|
+
end
|
78
|
+
|
79
|
+
def apps(*models)
|
80
|
+
models.map { |model| model[:app] }
|
81
|
+
end
|
82
|
+
|
83
|
+
def env_resolver(*args)
|
84
|
+
EY::Resolver.environment_resolver(user, to_query(args))
|
85
|
+
end
|
86
|
+
|
87
|
+
def envs(*models)
|
88
|
+
models.map { |model| model[:env] }
|
89
|
+
end
|
90
|
+
|
91
|
+
def account_resolver(*args)
|
92
|
+
EY::Resolver.account_resolver(user, to_query(args))
|
93
|
+
end
|
94
|
+
|
95
|
+
def accounts(*models)
|
96
|
+
models.map { |model| model[:account] }
|
97
|
+
end
|
66
98
|
end
|
67
99
|
|
68
100
|
RSpec.configure do |config|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey_resolver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gitable
|
16
|
-
requirement: &
|
16
|
+
requirement: &70293599453000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.2.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70293599453000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70293599452580 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70293599452580
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70293599452040 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '2.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70293599452040
|
47
47
|
description: Resolves apps, environments, app_environments and accounts using a set
|
48
48
|
of constraints
|
49
49
|
email:
|
@@ -92,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
segments:
|
94
94
|
- 0
|
95
|
-
hash:
|
95
|
+
hash: -4423758491052706735
|
96
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
segments:
|
103
103
|
- 0
|
104
|
-
hash:
|
104
|
+
hash: -4423758491052706735
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project: ey_resolver
|
107
107
|
rubygems_version: 1.8.15
|