Skip to content
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

Core tests #1162

Merged
merged 18 commits into from
Jan 27, 2020
Merged

Core tests #1162

merged 18 commits into from
Jan 27, 2020

Conversation

wcekan
Copy link
Contributor

@wcekan wcekan commented Jan 25, 2020

Description

Adding some missing tests.

  • dictionary field lookups
  • field coercion
  • field path building
  • check lifecycle handling during exceptions

Motivation and Context

Better elide-core code coverage

How Has This Been Tested?

Unit testing

License

I confirm that this contribution is made under an Apache 2.0 license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@coveralls
Copy link
Collaborator

coveralls commented Jan 25, 2020

Coverage Status

Coverage increased (+2.8%) to 79.863% when pulling b353779 on coreTests into d6e2093 on master.

@wcekan wcekan force-pushed the coreTests branch 2 times, most recently from 77b476c to a8294ec Compare January 25, 2020 22:24
@wcekan wcekan force-pushed the coreTests branch 6 times, most recently from 35b80d7 to 75d8630 Compare January 26, 2020 01:42
} catch (IOException e) {
throw new UncheckedIOException(e);
}
if (doc2.getData() == null) {
Copy link
Member

Choose a reason for hiding this comment

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

What's this for?

Copy link
Contributor Author

@wcekan wcekan Jan 27, 2020

Choose a reason for hiding this comment

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

See #1163. Moved there.

@@ -110,6 +117,7 @@ public PersistentResourceTest() {
badUserScope = new RequestScope(null, null, mock(DataStoreTransaction.class),
new User(-1), null, elideSettings);
reset(goodUserScope.getTransaction());
assertFalse(goodUserScope.isUseFilterExpressions());
Copy link
Member

Choose a reason for hiding this comment

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

This is not a test. Why use assert here?

Copy link
Contributor Author

@wcekan wcekan Jan 27, 2020

Choose a reason for hiding this comment

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

Why is this not a test? Will move.

@Test
public void testPatchRequestScope() {
DataStoreTransaction tx = mock(DataStoreTransaction.class);
PatchRequestScope parentScope =
Copy link
Member

Choose a reason for hiding this comment

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

Does the code actually nest patch scopes like this? I thought patch was the parent scope - but child scopes were always normal request scopes.

Copy link
Contributor Author

@wcekan wcekan Jan 27, 2020

Choose a reason for hiding this comment

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

Yes, they are nested. A new wrapper is generated for each operation in the patch extension. That is what this tests. See

https://github.com/yahoo/elide/blob/master/elide-core/src/main/java/com/yahoo/elide/extensions/JsonApiPatch.java#L65

dictionary.bindTrigger(Book.class, OnUpdatePreCommit.class, onUpdateDeferredCallback, true);
dictionary.bindTrigger(Book.class, OnUpdatePreSecurity.class, onUpdateImmediateCallback, true);
dictionary.bindTrigger(Book.class, OnUpdatePostCommit.class, onUpdatePostCommitCallback, true);
dictionary.bindTrigger(Author.class, OnUpdatePostCommit.class, onUpdatePostCommitAuthor, true);
// enable trace
Logger rootLogger = (Logger) LoggerFactory.getILoggerFactory().getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.setLevel(Level.TRACE);
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to leave this log level on?

Copy link
Contributor Author

@wcekan wcekan Jan 27, 2020

Choose a reason for hiding this comment

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

Yes, otherwise we are not testing logging works without throwing exceptions.
Otherwise you need to duplicate all these same tests except with logging on.

Copy link
Member

@aklish aklish left a comment

Choose a reason for hiding this comment

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

Nice coverage bump. Some minor comments/questions.

aklish
aklish previously approved these changes Jan 27, 2020
@aklish aklish merged commit 04b1fce into master Jan 27, 2020
@aklish aklish deleted the coreTests branch January 27, 2020 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants