Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Commit

Permalink
Merge branch 'regions'
Browse files Browse the repository at this point in the history
  • Loading branch information
csainty committed May 17, 2012
2 parents e3c96e7 + 27ba07d commit 691f936
Show file tree
Hide file tree
Showing 24 changed files with 215 additions and 39 deletions.
4 changes: 4 additions & 0 deletions Apphbify.Tests/Apphbify.Tests.csproj
Expand Up @@ -77,9 +77,11 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Bootstrapper\DoesRegionExist.cs" />
<Compile Include="Bootstrapper\When_requesting_the_home_page.cs" />
<Compile Include="DataStoreTests\GetAddonByKey.cs" />
<Compile Include="DataStoreTests\GetAllApps.cs" />
<Compile Include="DataStoreTests\GetAllRegions.cs" />
<Compile Include="DataStoreTests\GetAppByKey.cs" />
<Compile Include="Helpers\BrowserResponseExtensions.cs" />
<Compile Include="Helpers\TestingRazorConfiguration.cs" />
Expand All @@ -90,6 +92,8 @@
<Compile Include="Pages\About\When_displaying_the_about_page.cs" />
<Compile Include="Pages\AddEmailNotification\When_creating_the_hook_fails.cs" />
<Compile Include="Pages\Apps\When_displaying_the_apps_page.cs" />
<Compile Include="Pages\Deploy\When_an_invalid_region_id_is_specified.cs" />
<Compile Include="Pages\Deploy\When_no_region_id_is_specified.cs" />
<Compile Include="Pages\Deploy\When_addons_fail_to_install.cs" />
<Compile Include="Pages\Deploy\When_application_creation_fails.cs" />
<Compile Include="Pages\Deploy\When_code_deploy_fails.cs" />
Expand Down
20 changes: 20 additions & 0 deletions Apphbify.Tests/Bootstrapper/DoesRegionExist.cs
@@ -0,0 +1,20 @@
using Apphbify.Data;
using Xunit;

namespace Apphbify.Tests.Bootstrapper
{
public class DoesRegionExist
{
[Fact]
public void It_should_return_true_when_region_exists()
{
Assert.True(new DataStore().DoesRegionExist("amazon-web-services::us-east-1"));
}

[Fact]
public void It_should_return_false_when_region_does_not_exist()
{
Assert.False(new DataStore().DoesRegionExist("foo"));
}
}
}
13 changes: 13 additions & 0 deletions Apphbify.Tests/DataStoreTests/GetAllApps.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Apphbify.Data;
using Xunit;

Expand All @@ -18,5 +19,17 @@ public void Should_contain_entries()
{
Assert.NotEqual(0, _Apps.Count);
}

[Fact]
public void All_variables_should_not_be_null()
{
Assert.True(_Apps.All(d => d.Variables != null));
}

[Fact]
public void All_addons_should_not_be_null()
{
Assert.True(_Apps.All(d => d.Addons != null));
}
}
}
22 changes: 22 additions & 0 deletions Apphbify.Tests/DataStoreTests/GetAllRegions.cs
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using Apphbify.Data;
using Xunit;

namespace Apphbify.Tests.DataStoreTests
{
public class GetAllRegions
{
IList<Region> _Regions;

public GetAllRegions()
{
_Regions = new DataStore().GetAllRegions();
}

[Fact]
public void It_should_load_some_regions()
{
Assert.NotEqual(0, _Regions.Count);
}
}
}
5 changes: 3 additions & 2 deletions Apphbify.Tests/Pages/Deploy/When_addons_fail_to_install.cs
Expand Up @@ -18,7 +18,7 @@ public When_addons_fail_to_install()
{
_Deploy = new Mock<IDeploymentService>(MockBehavior.Strict);
string slug;
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.ErrorInstallingAddons);
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.ErrorInstallingAddons);
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
Expand All @@ -27,6 +27,7 @@ public When_addons_fail_to_install()
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("application_name", "JabbR Test");
with.FormValue("region_id", "amazon-web-services::us-east-1");
});
}

Expand All @@ -46,7 +47,7 @@ public void It_should_have_an_error_message()
public void It_should_have_fired_the_deployment()
{
string slug;
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
}
}
}
@@ -0,0 +1,37 @@
using Apphbify.Tests.Helpers;
using Nancy.Testing;
using Xunit;

namespace Apphbify.Tests.Pages.Deploy
{
public class When_an_invalid_region_id_is_specified
{
private Browser _Browser;
private BrowserResponse _Response;

public When_an_invalid_region_id_is_specified()
{
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
});
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("application_name", "foo");
with.FormValue("region_id", "foo");
});
}

[Fact]
public void It_should_redirect_to_get()
{
_Response.ShouldHaveRedirectedTo("/Deploy/jabbr");
}

[Fact]
public void It_should_include_an_error()
{
_Response.ShouldHaveErrorMessage();
}
}
}
Expand Up @@ -18,7 +18,7 @@ public When_application_creation_fails()
{
_Deploy = new Mock<IDeploymentService>(MockBehavior.Strict);
string slug;
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.UnableToCreateApplication);
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.UnableToCreateApplication);
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
Expand All @@ -27,6 +27,7 @@ public When_application_creation_fails()
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("application_name", "JabbR Test");
with.FormValue("region_id", "amazon-web-services::us-east-1");
});
}

Expand All @@ -46,7 +47,7 @@ public void It_should_have_an_error_message()
public void It_should_have_fired_the_deployment()
{
string slug;
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
}
}
}
5 changes: 3 additions & 2 deletions Apphbify.Tests/Pages/Deploy/When_code_deploy_fails.cs
Expand Up @@ -18,7 +18,7 @@ public When_code_deploy_fails()
{
_Deploy = new Mock<IDeploymentService>(MockBehavior.Strict);
string slug;
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.UnableToDeployCode);
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.UnableToDeployCode);
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
Expand All @@ -27,6 +27,7 @@ public When_code_deploy_fails()
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("application_name", "JabbR Test");
with.FormValue("region_id", "amazon-web-services::us-east-1");
});
}

Expand All @@ -46,7 +47,7 @@ public void It_should_have_an_error_message()
public void It_should_have_fired_the_deployment()
{
string slug;
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
}
}
}
Expand Up @@ -19,9 +19,9 @@ public When_config_variables_are_entered()
{
_Deploy = new Mock<IDeploymentService>(MockBehavior.Strict);
string slug;
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug))
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug))
.Returns(DeploymentResult.Success)
.Callback<string, App, Dictionary<string, string>, string>((name, app, vars, alug) =>
.Callback<string, string, App, Dictionary<string, string>, string>((name, region, app, vars, alug) =>
{
_ReceivedVars = vars;
}); ;
Expand All @@ -33,6 +33,7 @@ public When_config_variables_are_entered()
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("application_name", "JabbR Test");
with.FormValue("region_id", "amazon-web-services::us-east-1");
with.FormValue("auth.apiKey", "test api key");
with.FormValue("auth.appName", "test app name");
with.FormValue("googleAnalytics", "test analytics key");
Expand All @@ -55,7 +56,7 @@ public void It_should_have_a_success_message()
public void It_should_have_fired_the_deployment()
{
string slug;
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
}

[Fact]
Expand Down
Expand Up @@ -18,7 +18,7 @@ public When_deployment_fails_for_an_unknown_reason()
{
_Deploy = new Mock<IDeploymentService>(MockBehavior.Strict);
string slug;
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.Unspecified);
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.Unspecified);
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
Expand All @@ -27,6 +27,7 @@ public When_deployment_fails_for_an_unknown_reason()
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("application_name", "JabbR Test");
with.FormValue("region_id", "amazon-web-services::us-east-1");
});
}

Expand All @@ -46,7 +47,7 @@ public void It_should_have_an_error_message()
public void It_should_have_fired_the_deployment()
{
string slug;
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
}
}
}
5 changes: 3 additions & 2 deletions Apphbify.Tests/Pages/Deploy/When_deployment_succeeds.cs
Expand Up @@ -18,7 +18,7 @@ public When_deployment_succeeds()
{
_Deploy = new Mock<IDeploymentService>(MockBehavior.Strict);
string slug;
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.Success);
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.Success);
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
Expand All @@ -27,6 +27,7 @@ public When_deployment_succeeds()
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("application_name", "JabbR Test");
with.FormValue("region_id", "amazon-web-services::us-east-1");
});
}

Expand All @@ -46,7 +47,7 @@ public void It_should_have_a_success_message()
public void It_should_have_fired_the_deployment()
{
string slug;
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
_Deploy.Verify(d => d.Deploy("JabbR Test", "amazon-web-services::us-east-1", It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
}
}
}
Expand Up @@ -15,7 +15,10 @@ public When_no_application_name_is_specified()
{
with.LoggedInUser();
});
_Response = _Browser.Post("/Deploy/jabbr");
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("region_id", "amazon-web-services::us-east-1");
});
}

[Fact]
Expand Down
36 changes: 36 additions & 0 deletions Apphbify.Tests/Pages/Deploy/When_no_region_id_is_specified.cs
@@ -0,0 +1,36 @@
using Apphbify.Tests.Helpers;
using Nancy.Testing;
using Xunit;

namespace Apphbify.Tests.Pages.Deploy
{
public class When_no_region_id_is_specified
{
private Browser _Browser;
private BrowserResponse _Response;

public When_no_region_id_is_specified()
{
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
});
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("application_name", "foo");
});
}

[Fact]
public void It_should_redirect_to_get()
{
_Response.ShouldHaveRedirectedTo("/Deploy/jabbr");
}

[Fact]
public void It_should_include_an_error()
{
_Response.ShouldHaveErrorMessage();
}
}
}
5 changes: 3 additions & 2 deletions Apphbify.Tests/Pages/Deploy/When_variables_fail_to_set.cs
Expand Up @@ -18,7 +18,7 @@ public When_variables_fail_to_set()
{
_Deploy = new Mock<IDeploymentService>(MockBehavior.Strict);
string slug;
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.ErrorSettingVariables);
_Deploy.Setup(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug)).Returns(DeploymentResult.ErrorSettingVariables);
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
Expand All @@ -27,6 +27,7 @@ public When_variables_fail_to_set()
_Response = _Browser.Post("/Deploy/jabbr", with =>
{
with.FormValue("application_name", "JabbR Test");
with.FormValue("region_id", "amazon-web-services::us-east-1");
});
}

Expand All @@ -46,7 +47,7 @@ public void It_should_have_an_error_message()
public void It_should_have_fired_the_deployment()
{
string slug;
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
_Deploy.Verify(d => d.Deploy(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<App>(), It.IsAny<Dictionary<string, string>>(), out slug), Times.Once());
}
}
}
1 change: 1 addition & 0 deletions Apphbify/Apphbify.csproj
Expand Up @@ -163,6 +163,7 @@
<Content Include="Content\fonts\Ubuntu-RI-webfont.ttf" />
<Content Include="Content\fonts\Ubuntu-RI-webfont.woff" />
<None Include="Content\js\bootstrap.js" />
<EmbeddedResource Include="Regions.json" />
<Content Include="Resources\favicon.ico" />
<None Include="Content\js\bootstrap.modal.js" />
<None Include="Content\js\bootstrap.tooltip.js" />
Expand Down

0 comments on commit 691f936

Please sign in to comment.