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

Unit/Integration tests #342

Merged
merged 15 commits into from
Jan 22, 2021
Merged

Conversation

unclecheese
Copy link

No description provided.

@unclecheese unclecheese marked this pull request as draft December 16, 2020 03:08
@unclecheese unclecheese force-pushed the pulls/master/so-testy branch from 0f2d426 to 4bb9751 Compare December 16, 2020 03:34
@chillu chillu force-pushed the pulls/master/so-testy branch from b680f6d to 4c2139a Compare December 18, 2020 02:29
@unclecheese unclecheese force-pushed the pulls/master/so-testy branch from 4c2139a to 3f5c5d6 Compare January 17, 2021 22:51
Aaron Carlino and others added 8 commits January 20, 2021 15:43
The schema is used for two purposes:
1. Building: It converts config arrays (retrieved from YAML) to instance state, which is required to call `save()` and persist the schema for later use.
2. Fetching: It loads retrieves an existing persisted schema. This does not require any instance state.

`bootConfig()` was called in the constructor, and implied that it prepares the instance for operation. In fact, it only merges enough (global and local) config to set up a SchemaContext object. It does not validate the schema, or build out the instance state (types, models, etc).. At this point, the instance can be used for *some* operations such as retrieving the underlying GraphQL schema (via `fetch()`). This benefitted the main `Controller` use because other instance state is expensive to validate and create from config (via `applyConfig()`). In order to *actually* get a consistent schema (reflecting the YAML configuration), you also needed to call `loadFromConfig()`.

This change centralises the two step process (bootConfig, loadFromConfig) into a single one with an obvious name: `boot()`.
It also removes the need to store the intermediary merged config state on the instance, which is only required for diagnostic purposes and complicates state management.
Since the config state getter was removed, it also required removal of getSignature() - see silverstripe#343

Context: silverstripe#335 (comment)
Allowing setters on key and context *after* booting the schema
creates complex state management issues for no apparent benefit.
The related unit tests were fairly self-referential,
it does not appear that the setters are required for automation testing.
SchemaContextTest was reusing IntegrationTestResolver(s),
which then interfered with the original use case of those resolvers,
by returning __FUNCTION__ from resolve()
@chillu chillu force-pushed the pulls/master/so-testy branch from 5ce00ef to b40f3df Compare January 20, 2021 02:48
tests/Schema/IntegrationTest.php Outdated Show resolved Hide resolved
@@ -82,13 +82,14 @@ private static function addInheritance(Schema $schema, string $class, ?ModelType
// Merge with the parent model for inherited fields
if ($parentModel) {
$modelType->mergeWith($parentModel);
//$modelType->removeField(InheritanceChain::getName());
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be removed?

@chillu chillu marked this pull request as ready for review January 20, 2021 03:07
@chillu chillu changed the title WIP: Unit/Integration tests Unit/Integration tests Jan 20, 2021
Garion Herman and others added 5 commits January 20, 2021 16:51
Required to stop frameworktest breaking GraphQL v4,
for which compat was introduced after the 0.2.0 release.
This is likely temporary until we migrate to the shared travis config.
Changing QueryMiddleware to become a generic Middleware
was well intentioned: It could be used for other purposes outside of the query context,
for example if plugins started supporting middleware.
But in order to achieve this, it weakened the (query specific) parameter
signature into a generic $params argument, which makes it harder
to understand how to write valid middleware for developers.
On balance, that's a more important concern than saving a few
lines of code in writing a hypothetical second middleware implementation in the module.

Also re-added the existing tests from GraphQL v3
@chillu
Copy link
Member

chillu commented Jan 22, 2021

The Behat failure here is pre-existing, not related to the pull request - see https://travis-ci.com/github/silverstripe/silverstripe-asset-admin/jobs/473637116

Upstream is broken, and it's out of our control to fix
(Chrome bug) - see silverstripe/silverstripe-asset-admin#1163
@chillu chillu force-pushed the pulls/master/so-testy branch from 92203a6 to 7baaff2 Compare January 22, 2021 03:17
@chillu chillu merged commit 4ae2853 into silverstripe:master Jan 22, 2021
@chillu chillu deleted the pulls/master/so-testy branch January 22, 2021 03:19
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.

2 participants