Skip to content

Commit

Permalink
Fix the broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hnrkndrssn committed Feb 24, 2019
1 parent 1154a78 commit 49efc19
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Octokit.Reactive/Clients/IObservableMigrationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ IObservable<Migration> Start(
/// </remarks>
/// <param name="org">The organization of which to list migrations.</param>
/// <returns>List of most recent <see cref="Migration"/>s.</returns>
IObservable<IReadOnlyList<Migration>> GetAll(
IObservable<Migration> GetAll(
string org);

/// <summary>
Expand All @@ -48,7 +48,7 @@ IObservable<IReadOnlyList<Migration>> GetAll(
/// <param name="org">The organization of which to list migrations.</param>
/// <param name="options">Options for changing the API response</param>
/// <returns>List of most recent <see cref="Migration"/>s.</returns>
IObservable<IReadOnlyList<Migration>> GetAll(
IObservable<Migration> GetAll(
string org,
ApiOptions options);

Expand Down
11 changes: 8 additions & 3 deletions Octokit.Reactive/Clients/ObservableMigrationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;

namespace Octokit.Reactive
{
Expand All @@ -15,6 +16,7 @@ namespace Octokit.Reactive
public class ObservableMigrationsClient : IObservableMigrationsClient
{
private readonly IMigrationsClient _client;
private readonly IConnection _connection;

/// <summary>
/// Instantiates a GitHub Migrations API client.
Expand All @@ -25,6 +27,7 @@ public ObservableMigrationsClient(IGitHubClient client)
Ensure.ArgumentNotNull(client, nameof(client));

_client = client.Migration.Migrations;
_connection = client.Connection;
}

/// <summary>
Expand All @@ -50,14 +53,16 @@ public IObservable<Migration> Start(string org, StartMigrationRequest migration)
/// </remarks>
/// <param name="org">The organization of which to list migrations.</param>
/// <returns>List of most recent <see cref="Migration"/>s.</returns>
public IObservable<IReadOnlyList<Migration>> GetAll(string org)
public IObservable<Migration> GetAll(string org)
{
return GetAll(org, ApiOptions.None);
}

public IObservable<IReadOnlyList<Migration>> GetAll(string org, ApiOptions options)
public IObservable<Migration> GetAll(string org, ApiOptions options)
{
return _client.GetAll(org, options).ToObservable();
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Migration>(ApiUrls.EnterpriseMigrations(org), null, AcceptHeaders.MigrationsApiPreview, options);
}

/// <summary>
Expand Down
7 changes: 5 additions & 2 deletions Octokit.Tests/Reactive/ObservableMigrationsClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NSubstitute;
using Octokit.Reactive;
using Octokit.Reactive.Internal;
using Xunit;

namespace Octokit.Tests.Reactive
Expand Down Expand Up @@ -46,7 +48,7 @@ public void CallsIntoClient()
var client = new ObservableMigrationsClient(github);

client.GetAll("fake");
github.Migration.Migrations.Received(1).GetAll("fake", Args.ApiOptions);
github.Received().Migration.Migrations.GetAll("fake", Args.ApiOptions);
}

[Fact]
Expand All @@ -61,7 +63,8 @@ public void CallsIntoClientApiOptions()
};

client.GetAll("fake", options);
github.Migration.Migrations.Received(1).GetAll("fake", options);

github.Received().Migration.Migrations.GetAll("fake", options);
}
}

Expand Down

0 comments on commit 49efc19

Please sign in to comment.