From 01ec4f6399993e32cae0208cc7cf3a8289e4ba8a Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Tue, 29 Sep 2015 00:23:25 +1000 Subject: [PATCH] Update existing integration test to use new web hook helper class --- .../Clients/RepositoryHooksClientTests.cs | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs index 33d954ae95..cde8a366b5 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs @@ -63,15 +63,16 @@ public async Task CreateAWebHookForTestRepository() var repoName = Helper.MakeNameWithTimestamp("create-hooks-test"); var repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); + var url = "http://test.com/example"; + var contentType = WebHookContentType.Json; + var secret = "53cr37"; var config = new Dictionary { - { "content_type", "json" }, - { "url", "http://test.com/example" }, { "hostname", "http://hostname.url" }, { "username", "username" }, { "password", "password" } }; - var parameters = new NewRepositoryHook("windowsazure", config) + var parameters = new NewRepositoryWebHook("windowsazure", config, url, contentType, secret, false) { Events = new[] { "push" }, Active = false @@ -80,6 +81,8 @@ public async Task CreateAWebHookForTestRepository() var hook = await github.Repository.Hooks.Create(Helper.Credentials.Login, repository.Name, parameters); var baseHookUrl = CreateExpectedBaseHookUrl(repository.Url, hook.Id); + var webHookConfig = CreateExpectedConfigDictionary(config, url, contentType, secret); + Assert.Equal("windowsazure", hook.Name); Assert.Equal(new[] { "push" }.ToList(), hook.Events.ToList()); Assert.Equal(baseHookUrl, hook.Url); @@ -87,11 +90,22 @@ public async Task CreateAWebHookForTestRepository() Assert.Equal(baseHookUrl + "/pings", hook.PingUrl); Assert.NotNull(hook.CreatedAt); Assert.NotNull(hook.UpdatedAt); - Assert.Equal(config.Keys, hook.Config.Keys); - Assert.Equal(config.Values, hook.Config.Values); + Assert.Equal(webHookConfig.Keys, hook.Config.Keys); + Assert.Equal(webHookConfig.Values, hook.Config.Values); Assert.Equal(false, hook.Active); } + Dictionary CreateExpectedConfigDictionary(Dictionary config, string url, WebHookContentType contentType, string secret) + { + return config.Union(new Dictionary + { + { "url", url }, + { "content_type", contentType.ToString().ToLowerInvariant() }, + { "secret", secret }, + { "insecure_ssl", "0" } + }).ToDictionary(k => k.Key, v => v.Value); + } + string CreateExpectedBaseHookUrl(string url, int id) { return url + "/hooks/" + id;