Change "state" from string to enum in Migration Response.

This commit is contained in:
Devesh Khandelwal
2016-04-07 11:43:20 +05:30
parent 293ac97ba9
commit 5722754c21
2 changed files with 33 additions and 3 deletions

View File

@@ -113,7 +113,7 @@ namespace Octokit.Tests.Models
private static readonly Migration migration = new Migration(
id: 79,
guid: "0b989ba4-242f-11e5-81e1-c7b6966d2516",
state: "exported",
state: Migration.MigrationState.Exported,
lockRepositories: true,
excludeAttachments: false,
url: "https://api.github.com/orgs/octo-org/migrations/79",
@@ -135,6 +135,7 @@ namespace Octokit.Tests.Models
Assert.Equal("0b989ba4-242f-11e5-81e1-c7b6966d2516", _migration.Guid);
Assert.Equal(1, _migration.Repositories.Count);
Assert.Equal(1296269, _migration.Repositories[0].Id);
Assert.Equal(Migration.MigrationState.Pending, _migration.State);
}
}

View File

@@ -23,7 +23,7 @@ namespace Octokit
public Migration(
int id,
string guid,
string state,
MigrationState state,
bool lockRepositories,
bool excludeAttachments,
string url,
@@ -55,7 +55,7 @@ namespace Octokit
/// <summary>
/// The state of migration. Can be one of pending, exporting, exported and failed.
/// </summary>
public string State { get; private set; }
public MigrationState State { get; private set; }
/// <summary>
/// Whether to lock repositories.
@@ -94,5 +94,34 @@ namespace Octokit
return string.Format(CultureInfo.InvariantCulture, "Guid: {0}", Guid);
}
}
/// <summary>
/// State of a migration.
/// </summary>
/// <remarks>
/// See: https://developer.github.com/v3/migration/migrations/#get-the-status-of-a-migration
/// </remarks>
public enum MigrationState
{
/// <summary>
/// The migration hasn't started yet.
/// </summary>
Pending,
/// <summary>
/// The migration is in progress.
/// </summary>
Exporting,
/// <summary>
/// The migration finished successfully.
/// </summary>
Exported,
/// <summary>
/// The migration failed.
/// </summary>
Failed
}
}
}