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

chore: fix test assertions #28

Merged
merged 1 commit into from
Oct 20, 2022
Merged

chore: fix test assertions #28

merged 1 commit into from
Oct 20, 2022

Conversation

kvcache
Copy link
Contributor

@kvcache kvcache commented Oct 20, 2022

integration test assertions are currently missing all details in
the most expected case: When they got an error back.

This change makes tests output more helpful & verbose failures.
Replaces assertion messages like:

8) Momento\Tests\Cache\CacheClientTest::testListPushFrontFetchHappyPath
Failed asserting that null is not null.

/Users/kenny/gits/client-sdk-php/tests/Cache/CacheClientTest.php:427

9) Momento\Tests\Cache\CacheClientTest::testListPushFront_TruncateList
Failed asserting that null is not null.

/Users/kenny/gits/client-sdk-php/tests/Cache/CacheClientTest.php:480

With something a little more like:

35) Momento\Tests\Cache\CacheClientTest::testListPushBack_NoRefreshTtl
Failed asserting that Momento\Cache\CacheOperationTypes\CacheListFetchResponseError Object &00000000000009a20000000000000000 (
    'baseType' => 'Momento\Cache\CacheOperationTypes\CacheListFetchResponse'
    'innerException' => Momento\Cache\Errors\ServerUnavailableError Object &00000000000009a70000000000000000 (
        'message' => 'Resource unavailable'
        'string' => ''
        'code' => 14
        'file' => '/Users/kenny/gits/client-sdk-php/src/Utilities/_ErrorConverter.php'
        'line' => 46
        'previous' => null
        'errorCode' => Momento\Cache\Errors\MomentoErrorCode Object &00000000000006690000000000000000 (
            'name' => 'SERVER_UNAVAILABLE'
        )
        'messageWrapper' => 'The server was unable to handle the request; consider retrying.  If the error persists, please contact us at support@momentohq.com'
    )
    'errorCode' => Momento\Cache\Errors\MomentoErrorCode Object &00000000000006690000000000000000
    'message' => 'The server was unable to handle the request; consider retrying.  If the error persists, please contact us at support@momentohq.com: Resource unavailable'
) is null.

/Users/kenny/gits/client-sdk-php/tests/Cache/CacheClientTest.php:619

36) Momento\Tests\Cache\CacheClientTest::testListPushFront_NoRefreshTtl
Failed asserting that Momento\Cache\CacheOperationTypes\CacheListFetchResponseError Object &00000000000009b80000000000000000 (
    'baseType' => 'Momento\Cache\CacheOperationTypes\CacheListFetchResponse'
    'innerException' => Momento\Cache\Errors\ServerUnavailableError Object &00000000000009bd0000000000000000 (
        'message' => 'Resource unavailable'
        'string' => ''
        'code' => 14
        'file' => '/Users/kenny/gits/client-sdk-php/src/Utilities/_ErrorConverter.php'
        'line' => 46
        'previous' => null
        'errorCode' => Momento\Cache\Errors\MomentoErrorCode Object &00000000000006690000000000000000 (
            'name' => 'SERVER_UNAVAILABLE'
        )
        'messageWrapper' => 'The server was unable to handle the request; consider retrying.  If the error persists, please contact us at support@momentohq.com'
    )
    'errorCode' => Momento\Cache\Errors\MomentoErrorCode Object &00000000000006690000000000000000
    'message' => 'The server was unable to handle the request; consider retrying.  If the error persists, please contact us at support@momentohq.com: Resource unavailable'
) is null.

/Users/kenny/gits/client-sdk-php/tests/Cache/CacheClientTest.php:518

We can certainly do more to make these messages better, but at least
this shows errors that come back from the server

integration test assertions are currently missing all details in
the most expected case: When they got an error back.

This change makes tests output more helpful & verbose failures:
```
35) Momento\Tests\Cache\CacheClientTest::testListPushBack_NoRefreshTtl
Failed asserting that Momento\Cache\CacheOperationTypes\CacheListFetchResponseError Object &00000000000009a20000000000000000 (
    'baseType' => 'Momento\Cache\CacheOperationTypes\CacheListFetchResponse'
    'innerException' => Momento\Cache\Errors\ServerUnavailableError Object &00000000000009a70000000000000000 (
        'message' => 'Resource unavailable'
        'string' => ''
        'code' => 14
        'file' => '/Users/kenny/gits/client-sdk-php/src/Utilities/_ErrorConverter.php'
        'line' => 46
        'previous' => null
        'errorCode' => Momento\Cache\Errors\MomentoErrorCode Object &00000000000006690000000000000000 (
            'name' => 'SERVER_UNAVAILABLE'
        )
        'messageWrapper' => 'The server was unable to handle the request; consider retrying.  If the error persists, please contact us at support@momentohq.com'
    )
    'errorCode' => Momento\Cache\Errors\MomentoErrorCode Object &00000000000006690000000000000000
    'message' => 'The server was unable to handle the request; consider retrying.  If the error persists, please contact us at support@momentohq.com: Resource unavailable'
) is null.

/Users/kenny/gits/client-sdk-php/tests/Cache/CacheClientTest.php:619

36) Momento\Tests\Cache\CacheClientTest::testListPushFront_NoRefreshTtl
Failed asserting that Momento\Cache\CacheOperationTypes\CacheListFetchResponseError Object &00000000000009b80000000000000000 (
    'baseType' => 'Momento\Cache\CacheOperationTypes\CacheListFetchResponse'
    'innerException' => Momento\Cache\Errors\ServerUnavailableError Object &00000000000009bd0000000000000000 (
        'message' => 'Resource unavailable'
        'string' => ''
        'code' => 14
        'file' => '/Users/kenny/gits/client-sdk-php/src/Utilities/_ErrorConverter.php'
        'line' => 46
        'previous' => null
        'errorCode' => Momento\Cache\Errors\MomentoErrorCode Object &00000000000006690000000000000000 (
            'name' => 'SERVER_UNAVAILABLE'
        )
        'messageWrapper' => 'The server was unable to handle the request; consider retrying.  If the error persists, please contact us at support@momentohq.com'
    )
    'errorCode' => Momento\Cache\Errors\MomentoErrorCode Object &00000000000006690000000000000000
    'message' => 'The server was unable to handle the request; consider retrying.  If the error persists, please contact us at support@momentohq.com: Resource unavailable'
) is null.

/Users/kenny/gits/client-sdk-php/tests/Cache/CacheClientTest.php:518
```

We can certainly do more to make these messages better, but at least
this shows errors that come back from the server
@pgautier404 pgautier404 merged commit e2280be into momentohq:main Oct 20, 2022
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