Permalink
Browse files

making dropkick deploy fail if you havent mapped all of the roles

closes #32
  • Loading branch information...
drusellers committed Jan 24, 2012
1 parent ca2e484 commit 663f0ed36a84cb3586530979825def4f7ff9b9ae
@@ -10,6 +10,7 @@
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
+
namespace dropkick.tests.Configuration.Dsl
{
using dropkick.Configuration.Dsl;
@@ -0,0 +1,35 @@
+using NUnit.Framework;
+using dropkick.Configuration.Dsl;
+using dropkick.Engine;
+using dropkick.Exceptions;
+using dropkick.tests.TestObjects;
+
+namespace dropkick.tests.Configuration.Dsl
+{
+ [TestFixture]
+ public class should_throw_if_missing_a_mapped_role
+ {
+ public TwoRoleDeploy Deployment { get; private set; }
+ public DropkickDeploymentInspector Inspector { get; private set; }
+ public RoleToServerMap Map { get; private set; }
+
+ [TestFixtureSetUp]
+ public void EstablishContext()
+ {
+ Deployment = new TwoRoleDeploy();
+ Deployment.Initialize(new SampleConfiguration());
+
+ Map = new RoleToServerMap();
+ Map.AddMap("Web", "SrvTopeka09");
+ Map.AddMap("Web", "SrvTopeka19");
+ Inspector = new DropkickDeploymentInspector(Map);
+ }
+
+ [Test]
+ [ExpectedException(typeof(DeploymentConfigurationException))]
+ public void X()
+ {
+ var x = Inspector.GetPlan(Deployment);
+ }
+ }
+}
@@ -98,6 +98,7 @@
<Compile Include="Configuration\Dsl\IisProtoTaskProcessModelSpec.cs" />
<Compile Include="Configuration\Dsl\ProcessModelIdentityTranslation.cs" />
<Compile Include="Configuration\Dsl\roundhouse\RoundhouseProtoTest.cs" />
+ <Compile Include="Configuration\Dsl\should_throw_if_missing_a_mapped_role.cs" />
<Compile Include="Configuration\Dsl\WithTwoPartDeployContext.cs" />
<Compile Include="Configuration\Dsl\Verification_Demos.cs" />
<Compile Include="DeploymentModel\DeploymentPlanSpecs.cs" />
@@ -23,6 +23,7 @@ public interface Deployment :
{
void Initialize(object settings);
bool HardPrompt { get; }
+ IEnumerable<string> Roles { get; }
}
public class Deployment<Inheritor, SETTINGS> :
@@ -63,6 +64,11 @@ public void InspectWith(DeploymentInspector inspector)
#endregion
+ public IEnumerable<string> Roles
+ {
+ get { return _roles.Keys; }
+ }
+
public bool HardPrompt { get; private set; }
void InitializeParts()
@@ -9,7 +9,11 @@
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations under the License.
+// specific language governing permissions and limitations under the License.
+
+using System.Linq;
+using dropkick.Exceptions;
+
namespace dropkick.Configuration.Dsl
{
using System;
@@ -90,13 +94,28 @@ public bool Look(ProtoTask protoTask)
return true;
}
- public DeploymentPlan GetPlan(Deployment deployment)
- {
+ public DeploymentPlan GetPlan(Deployment deployment)
+ {
+ verifyRolesAreMapped(deployment);
+
deployment.InspectWith(this);
return _plan;
- }
-
+ }
+
+ void verifyRolesAreMapped(Deployment deployment)
+ {
+ var mappedRoles = _serverMappings.Roles();
+ var deploymentRoles = deployment.Roles;
+ foreach(var role in deploymentRoles)
+ {
+ if(!mappedRoles.Contains(role))
+ {
+ throw new DeploymentConfigurationException("You have not mapped a server to role '{0}'".FormatWith(role));
+ }
+ }
+ }
+
bool ShouldNotProcessRole(string role)
{
if(_rolesOfInterest.Count == 0) return false;
@@ -57,5 +57,10 @@ public void Initialize(object settings)
{
throw new NotImplementedException();
}
+
+ public IEnumerable<string> Roles
+ {
+ get { throw new NotImplementedException(); }
+ }
}
}

0 comments on commit 663f0ed

Please sign in to comment.