-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement GetLicenseContents() method for getting repository's licens…
…e info
- Loading branch information
Showing
15 changed files
with
355 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Octokit.Internal; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Models | ||
{ | ||
public class LicenseMetadataTests | ||
{ | ||
[Fact] | ||
public void CanBeDeserializedFromLicenseJson() | ||
{ | ||
const string json = @"{ | ||
""key"": ""mit"", | ||
""name"": ""MIT License"", | ||
""spdx_id"": ""MIT"", | ||
""url"": ""https://api.github.com/licenses/mit"", | ||
""featured"": true | ||
}"; | ||
var serializer = new SimpleJsonSerializer(); | ||
|
||
var license = serializer.Deserialize<LicenseMetadata>(json); | ||
|
||
Assert.Equal("mit", license.Key); | ||
Assert.Equal("MIT License", license.Name); | ||
Assert.Equal("MIT", license.SpdxId); | ||
Assert.Equal("https://api.github.com/licenses/mit", license.Url); | ||
Assert.True(license.Featured); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Octokit.Internal; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Models | ||
{ | ||
public class RepositoryContentLicenseTests | ||
{ | ||
[Fact] | ||
public void CanBeDeserializedFromRepositoryContentLicenseJson() | ||
{ | ||
const string json = @"{ | ||
""name"": ""LICENSE"", | ||
""path"": ""LICENSE"", | ||
""sha"": ""401c59dcc4570b954dd6d345e76199e1f4e76266"", | ||
""size"": 1077, | ||
""url"": ""https://api.github.com/repos/benbalter/gman/contents/LICENSE?ref=master"", | ||
""html_url"": ""https://github.com/benbalter/gman/blob/master/LICENSE"", | ||
""git_url"": ""https://api.github.com/repos/benbalter/gman/git/blobs/401c59dcc4570b954dd6d345e76199e1f4e76266"", | ||
""download_url"": ""https://raw.githubusercontent.com/benbalter/gman/master/LICENSE?lab=true"", | ||
""type"": ""file"", | ||
""content"": ""VGhlIE1JVCBMaWNlbnNlIChNSVQpCgpDb3B5cmlnaHQgKGMpIDIwMTMgQmVu\nIEJhbHRlcgoKUGVybWlzc2lvbiBpcyBoZXJlYnkgZ3JhbnRlZCwgZnJlZSBv\nZiBjaGFyZ2UsIHRvIGFueSBwZXJzb24gb2J0YWluaW5nIGEgY29weSBvZgp0\naGlzIHNvZnR3YXJlIGFuZCBhc3NvY2lhdGVkIGRvY3VtZW50YXRpb24gZmls\nZXMgKHRoZSAiU29mdHdhcmUiKSwgdG8gZGVhbCBpbgp0aGUgU29mdHdhcmUg\nd2l0aG91dCByZXN0cmljdGlvbiwgaW5jbHVkaW5nIHdpdGhvdXQgbGltaXRh\ndGlvbiB0aGUgcmlnaHRzIHRvCnVzZSwgY29weSwgbW9kaWZ5LCBtZXJnZSwg\ncHVibGlzaCwgZGlzdHJpYnV0ZSwgc3VibGljZW5zZSwgYW5kL29yIHNlbGwg\n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?ref=master"", | ||
""git"": ""https://api.github.com/repos/benbalter/gman/git/blobs/401c59dcc4570b954dd6d345e76199e1f4e76266"", | ||
""html"": ""https://github.com/benbalter/gman/blob/master/LICENSE"" | ||
}, | ||
""license"": { | ||
""key"": ""mit"", | ||
""name"": ""MIT License"", | ||
""spdx_id"": ""MIT"", | ||
""url"": ""https://api.github.com/licenses/mit"", | ||
""featured"": true | ||
} | ||
}"; | ||
var serializer = new SimpleJsonSerializer(); | ||
|
||
var license = serializer.Deserialize<RepositoryContentLicense>(json); | ||
var licenseMetadata = license.License; | ||
|
||
Assert.Equal("LICENSE", license.Name); | ||
Assert.Equal("LICENSE", license.Path); | ||
Assert.Equal("401c59dcc4570b954dd6d345e76199e1f4e76266", license.Sha); | ||
Assert.NotNull(license.License); | ||
Assert.Equal("mit", licenseMetadata.Key); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.