Skip to content

Commit

Permalink
Update GetArchive() to return a byte array. All tests passing. 👍
Browse files Browse the repository at this point in the history
  • Loading branch information
devkhan committed May 20, 2016
1 parent 822a757 commit 798fe1f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Octokit.Reactive/Clients/IObservableMigrationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ IObservable<List<Migration>> GetAll(
string org);

/// <summary>
/// Get the status of a migration
/// Get the status of a migration.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/migration/migrations/#get-the-status-of-a-migration
Expand All @@ -54,15 +54,15 @@ IObservable<Migration> Get(
int id);

/// <summary>
/// Fetches the URL to a migration archive.
/// Get the migration archive.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/migration/migrations/#download-a-migration-archive
/// </remarks>
/// <param name="org">The organization of which the migration was.</param>
/// <param name="id">The ID of the migration.</param>
/// <returns>URL as a string of the download link of the archive.</returns>
IObservable<string> GetArchive(
/// <returns>The binary contents of the archive as a byte array.</returns>
IObservable<byte[]> GetArchive(
string org,
int id);

Expand Down
6 changes: 3 additions & 3 deletions Octokit.Reactive/Clients/ObservableMigrationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ public IObservable<Migration> Get(string org, int id)
}

/// <summary>
/// Fetches the URL to a migration archive.
/// Get the migration archive.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/migration/migrations/#download-a-migration-archive
/// </remarks>
/// <param name="org">The organization of which the migration was.</param>
/// <param name="id">The ID of the migration.</param>
/// <returns>URL as a string of the download link of the archive.</returns>
public IObservable<string> GetArchive(string org, int id)
/// <returns>The binary contents of the archive as a byte array.</returns>
public IObservable<byte[]> GetArchive(string org, int id)
{
return _client.GetArchive(org, id).ToObservable();
}
Expand Down
6 changes: 3 additions & 3 deletions Octokit.Tests.Integration/Clients/MigrationsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public async Task CanGetArchive()
Thread.Sleep(2000);
}

var url = await _gitHub.Migration.Migrations.GetArchive(_orgName, _migrationContext.Id);

Assert.NotEmpty(url);
var contents = await _gitHub.Migration.Migrations.GetArchive(_orgName, _migrationContext.Id);
Assert.NotEmpty(contents);
}

[IntegrationTest]
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Tests/Clients/MigrationsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void RequestsCorrectUrl()

client.GetArchive("fake", 69);

connection.Received().Get<string>(
connection.Connection.Received().Get<byte[]>(
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations/69/archive"),
null,
AcceptHeaders.MigrationsApiPreview);
Expand Down
6 changes: 3 additions & 3 deletions Octokit/Clients/IMigrationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ Task<Migration> Get(
int id);

/// <summary>
/// Fetches the URL to a migration archive.
/// Get the migration archive.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/migration/migrations/#download-a-migration-archive
/// </remarks>
/// <param name="org">The organization of which the migration was.</param>
/// <param name="id">The ID of the migration.</param>
/// <returns>URL as a string of the download link of the archive.</returns>
Task<string> GetArchive(
/// <returns>The binary contents of the archive as a byte array.</returns>
Task<byte[]> GetArchive(
string org,
int id);

Expand Down
9 changes: 5 additions & 4 deletions Octokit/Clients/MigrationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,22 @@ public async Task<Migration> Get(string org, int id)
}

/// <summary>
/// Fetches the URL to a migration archive.
/// Get the migration archive.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/migration/migrations/#download-a-migration-archive
/// </remarks>
/// <param name="org">The organization of which the migration was.</param>
/// <param name="id">The ID of the migration.</param>
/// <returns>URL as a string of the download link of the archive.</returns>
public async Task<string> GetArchive(string org, int id)
/// <returns>The binary contents of the archive as a byte array.</returns>
public async Task<byte[]> GetArchive(string org, int id)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");

var endpoint = ApiUrls.EnterpriseMigrationArchive(org, id);
var response = await Connection.Get<byte[]>(endpoint, null, AcceptHeaders.MigrationsApiPreview);

return await ApiConnection.Get<string>(endpoint, null, AcceptHeaders.MigrationsApiPreview);
return response.Body;
}

/// <summary>
Expand Down

0 comments on commit 798fe1f

Please sign in to comment.