-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Approved] Add repository topics #2246
Changes from 48 commits
220e9a3
1d0cb56
3fa7807
56295b3
21d3bbd
4b3e57f
697d3d6
efd373e
620cb26
dd518d3
091bff0
cb5a06c
4a178ea
af48670
e68a5b8
ad9b819
52db2ab
fca13f4
0b88b7a
1cd3116
456f431
ebbe318
7d8d0d7
95f102a
67998dc
ca9e8e9
7761dbd
9b126e5
1e7ac1d
1792546
fd7a2be
0d6da2a
327ee27
c9ed7a7
19ea9fd
27d4d68
6068b1b
fe182e1
b7c6901
5dba2fd
e55273b
30b2215
cd0f082
cdbb96b
550f4e3
3e10bc2
a6c49ed
04161cf
4b62ec0
257be14
5fb88ad
8730206
84d6144
fa94465
c5574ed
2bc3df5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1371,6 +1371,93 @@ public async Task GetsEmptyLanguagesWhenNoneWithRepositoryId() | |
} | ||
} | ||
|
||
public class TheReplaceAllTopicsMethod : IDisposable | ||
{ | ||
readonly IGitHubClient _github = Helper.GetAuthenticatedClient(); | ||
readonly RepositoryTopics _defaultTopics = new RepositoryTopics(new List<string> { "blog", "ruby", "jekyll" }); | ||
const string theRepoOwner = "SeanKilleen"; | ||
const string theRepository = "seankilleen.github.io"; | ||
|
||
[IntegrationTest] | ||
public async Task ClearsTopicsWithAnEmptyList() | ||
{ | ||
var result = await _github.Repository.ReplaceAllTopics(theRepoOwner, theRepository, new RepositoryTopics()); | ||
Assert.Empty(result.Names); | ||
|
||
var doubleCheck = await _github.Repository.GetAllTopics(theRepoOwner, theRepository); | ||
Assert.Empty((doubleCheck.Names)); | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task ClearsTopicsWithAnEmptyListWhenUsingRepoId() | ||
{ | ||
var repo = await _github.Repository.Get(theRepoOwner, theRepository); | ||
var result = await _github.Repository.ReplaceAllTopics(repo.Id, new RepositoryTopics()); | ||
Assert.Empty(result.Names); | ||
|
||
var doubleCheck = await _github.Repository.GetAllTopics(theRepoOwner, theRepository); | ||
Assert.Empty((doubleCheck.Names)); | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task ReplacesTopicsWithAList() | ||
{ | ||
var defaultTopicsList = new RepositoryTopics(_defaultTopics.Names); | ||
var result = await _github.Repository.ReplaceAllTopics(theRepoOwner, theRepository, defaultTopicsList); | ||
|
||
Assert.NotEmpty(result.Names); | ||
Assert.Contains(result.Names, item => _defaultTopics.Names.Contains(item, StringComparer.InvariantCultureIgnoreCase)); | ||
|
||
var doubleCheck = await _github.Repository.GetAllTopics(theRepoOwner, theRepository); | ||
SeanKilleen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Assert.Contains(doubleCheck.Names, item => _defaultTopics.Names.Contains(item, StringComparer.InvariantCultureIgnoreCase)); | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task ReplacesTopicsWithAListWhenUsingRepoId() | ||
{ | ||
var defaultTopicsList = new RepositoryTopics(_defaultTopics.Names); | ||
var repo = await _github.Repository.Get(theRepoOwner, theRepository); | ||
var result = await _github.Repository.ReplaceAllTopics(repo.Id, defaultTopicsList); | ||
|
||
Assert.NotEmpty(result.Names); | ||
Assert.Contains(result.Names, item => _defaultTopics.Names.Contains(item, StringComparer.InvariantCultureIgnoreCase)); | ||
|
||
var doubleCheck = await _github.Repository.GetAllTopics(theRepoOwner, theRepository); | ||
Assert.Contains(doubleCheck.Names, item => _defaultTopics.Names.Contains(item, StringComparer.InvariantCultureIgnoreCase)); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_github.Repository.ReplaceAllTopics(theRepoOwner, theRepository, _defaultTopics).ConfigureAwait(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my earlier example about |
||
} | ||
} | ||
public class TheGetAllTopicsMethod | ||
{ | ||
[IntegrationTest] | ||
public async Task GetsTopicsByOwnerAndName() | ||
{ | ||
var github = Helper.GetAnonymousClient(); | ||
var result = await github.Repository.GetAllTopics("SeanKilleen", "seankilleen.github.io"); | ||
|
||
Assert.Contains("blog", result.Names); | ||
Assert.Contains("ruby", result.Names); | ||
Assert.Contains("jekyll", result.Names); | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task GetsTopicsByRepoID() | ||
{ | ||
var github = Helper.GetAnonymousClient(); | ||
var repo = await github.Repository.Get("SeanKilleen", "seankilleen.github.io"); | ||
var result = await github.Repository.GetAllTopics(repo.Id); | ||
|
||
Assert.Contains("blog", result.Names); | ||
Assert.Contains("ruby", result.Names); | ||
Assert.Contains("jekyll", result.Names); | ||
} | ||
|
||
} | ||
|
||
public class TheGetAllTagsMethod | ||
{ | ||
[IntegrationTest] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My memory is a bit hazy, but I think there are test helpers for creating a repository. That way an integration can create a repository, do the test stuff, then delete the repository at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.