Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Conversation

@shana
Copy link
Contributor

@shana shana commented Feb 1, 2018

Ugh, what a mess. While fixing #1319, I came across a bunch of repository tests that were not actually using the code that the app is using.

Moved those tests to use the real API and deleted the old deprecated ModelService methods, and in the process fixed an old TrackingCollection bug where the OriginalCompleted observable would finish before all items have been processed.

Added exception catching to various places so we don't crash if keys aren't found or the network is down while accessing data.

This needs #1449 for tests to pass.

Assert.AreEqual(3, fetched.Count);
Assert.AreEqual("snoopy", fetched[0].Login);
Assert.AreEqual("github", fetched[1].Login);
Assert.AreEqual("fake", fetched[2].Login);
Copy link
Contributor

@grokys grokys Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Assert.That constraint model is preferred for nunit 3 apparently. See #1411 (comment) and the surrounding comments for context on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. It's just that it inverts the order of the parameters, makes it even more confusing than usual. I'll fix these then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we need to switch the order of parameters in quite a few tests if we want to be technically correct. However, it doesn't actually impact the testing and it's tedious work...

@grokys
Copy link
Contributor

grokys commented Feb 6, 2018

Also, I think the fix for TrackingCollection should probably be in a separate PR...

@grokys grokys mentioned this pull request Feb 12, 2018
@grokys grokys force-pushed the fixes/modelservice-bugs branch from 10786d1 to 648d67c Compare February 13, 2018 13:57
await repositories.OriginalCompleted;

// the first time we do this, it should fetch from the API
apiClient.Received().GetRepositories();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is warning that the result is not awaited. Need to add await here.

repositories.Subscribe();
await repositories.OriginalCompleted;
// the second time we do this, it should not fetch
apiClient.DidNotReceive().GetRepositories();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

 Conflicts:
	test/UnitTests/GitHub.App/ViewModels/Dialog/RepositoryCloneViewModelTests.cs
`apiClient.GetRepositories()` is `async` so an `await` needs to be added to the `Received()`/`DidNotReceive` calls to prevent compiler warnings.
Line 155 (`apiClient.GetUser().Returns(Observable.Return(CreateOctokitUser("snoopy")));`) should be doing this.
The ordering of `expectedRepos` vs `repositories` is not important.
@grokys grokys requested a review from jcansdale March 13, 2018 12:26
@jcansdale jcansdale closed this Mar 10, 2020
@jcansdale jcansdale deleted the fixes/modelservice-bugs branch March 10, 2020 11:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants