100 lines
No EOL
5.5 KiB
JSON
100 lines
No EOL
5.5 KiB
JSON
{
|
|
"uuid": [
|
|
{
|
|
"value": "6299e640-9328-434d-af8c-3637f92e9bfd"
|
|
}
|
|
],
|
|
"langcode": [
|
|
{
|
|
"value": "en"
|
|
}
|
|
],
|
|
"type": [
|
|
{
|
|
"target_id": "daily_email",
|
|
"target_type": "node_type",
|
|
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
|
|
}
|
|
],
|
|
"revision_timestamp": [
|
|
{
|
|
"value": "2025-04-21T01:22:00+00:00"
|
|
}
|
|
],
|
|
"revision_uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"revision_log": [],
|
|
"status": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"title": [
|
|
{
|
|
"value": "Tests are living documentation\n"
|
|
}
|
|
],
|
|
"created": [
|
|
{
|
|
"value": "2022-12-30T00:00:00+00:00"
|
|
}
|
|
],
|
|
"changed": [
|
|
{
|
|
"value": "2025-04-21T01:22:00+00:00"
|
|
}
|
|
],
|
|
"promote": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"sticky": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"default_langcode": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"revision_translation_affected": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"path": [
|
|
{
|
|
"alias": "\/daily\/2022\/12\/30\/tests-are-living-documentation",
|
|
"langcode": null
|
|
}
|
|
],
|
|
"body": [
|
|
{
|
|
"value": "\n <p>Today I was working on a project and made a one-line change that updated a single value within an API response.<\/p>\n\n<p>Unexpectedly, it caused a test to fail. The API response returned a 500 status code instead of the expected 201 code.<\/p>\n\n<p>I reverted the change locally and ensured that the test passed again, so I knew it was causing the failure.<\/p>\n\n<h2 id=\"fixing-the-failure\">Fixing the failure<\/h2>\n\n<p>The change was removing a hard-coded part of a URL to a dynamic one, using Drupal's <code>Settings<\/code> class.<\/p>\n\n<p>I was retrieving a value from it, but as there was no value being set within the test, it was returning a null value and causing the 500 error code.<\/p>\n\n<h2 id=\"how-does-the-settings-class-work%3F\">How does the Settings class work?<\/h2>\n\n<p>To fix the test failure, I needed to learn how to set a Settings value within a test.<\/p>\n\n<p>To do this, I looked for and found the test for the Settings class itself. I saw how it was being set there, did the same in my test, fixed the failure and got my test passing again.<\/p>\n\n<h2 id=\"tests-are-living-documentation\">Tests are living documentation<\/h2>\n\n<p>As well as verifying things work when they are written, tests also act as long-term documentation. They can be run at any point to ensure that they still pass and are a reference to other developers on how the code should work.<\/p>\n\n<p>Rather than a Confluence page, a README file or code comments which can become out of date, if a test becomes outdated, it will fail and make developers aware, as well as break any CI pipeline that it runs in.<\/p>\n\n<p>By writing tests, you're ensuring that your code works as expected and documenting it at the same time.<\/p>\n\n ",
|
|
"format": "full_html",
|
|
"processed": "\n <p>Today I was working on a project and made a one-line change that updated a single value within an API response.<\/p>\n\n<p>Unexpectedly, it caused a test to fail. The API response returned a 500 status code instead of the expected 201 code.<\/p>\n\n<p>I reverted the change locally and ensured that the test passed again, so I knew it was causing the failure.<\/p>\n\n<h2 id=\"fixing-the-failure\">Fixing the failure<\/h2>\n\n<p>The change was removing a hard-coded part of a URL to a dynamic one, using Drupal's <code>Settings<\/code> class.<\/p>\n\n<p>I was retrieving a value from it, but as there was no value being set within the test, it was returning a null value and causing the 500 error code.<\/p>\n\n<h2 id=\"how-does-the-settings-class-work%3F\">How does the Settings class work?<\/h2>\n\n<p>To fix the test failure, I needed to learn how to set a Settings value within a test.<\/p>\n\n<p>To do this, I looked for and found the test for the Settings class itself. I saw how it was being set there, did the same in my test, fixed the failure and got my test passing again.<\/p>\n\n<h2 id=\"tests-are-living-documentation\">Tests are living documentation<\/h2>\n\n<p>As well as verifying things work when they are written, tests also act as long-term documentation. They can be run at any point to ensure that they still pass and are a reference to other developers on how the code should work.<\/p>\n\n<p>Rather than a Confluence page, a README file or code comments which can become out of date, if a test becomes outdated, it will fail and make developers aware, as well as break any CI pipeline that it runs in.<\/p>\n\n<p>By writing tests, you're ensuring that your code works as expected and documenting it at the same time.<\/p>\n\n ",
|
|
"summary": null
|
|
}
|
|
],
|
|
"feeds_item": [
|
|
{
|
|
"imported": "2025-04-21T01:22:00+00:00",
|
|
"guid": null,
|
|
"hash": "fd83c2fde1dc9ee8eddd826af1ec88b8",
|
|
"target_type": "feeds_feed",
|
|
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
|
|
}
|
|
]
|
|
} |