mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-22 19:32:54 +03:00
Added a set of tests for our tinybird setup
- TODO: make these run in CI - Right now you run them by running `yarn tb` and then `./script/branch_and_test.sh` - These are snapshot tests that check we get the desired result Co-authored-by: alejandromav <hi@alejandromav.com>
This commit is contained in:
parent
e3268c8c59
commit
606fcbabe7
@ -1,5 +1,9 @@
|
||||
# Datasource fixtures
|
||||
|
||||
## NDJSON files
|
||||
These files are fixtures used for running tests
|
||||
|
||||
## Schema JSON files
|
||||
The file mockingbird-schema.json is a schema for generating fake data using the Mockingbird CLI.
|
||||
|
||||
The CLI is installed via npm:
|
||||
|
31
ghost/tinybird/datasources/fixtures/analytics_events.ndjson
Normal file
31
ghost/tinybird/datasources/fixtures/analytics_events.ndjson
Normal file
@ -0,0 +1,31 @@
|
||||
{"timestamp":"2100-01-01 01:06:15","session_id":"e5c37e25-ed9e-4940-a2be-bc49149d991a","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"AhrefsBot/7.0; +http://ahrefs.com/robot/\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://petty-queen.com\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-01 00:51:17","session_id":"1267b782-e5a1-4334-8cf6-771d72bbc28e","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"d4678fdf-824c-4d5f-a5fe-c713d409faac\",\"member_status\":\"free\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/533.2.1 (KHTML, like Gecko) Chrome/13.0.868.0 Safari/533.2.1\",\"locale\":\"es-ES\",\"location\":\"ES\",\"referrer\":\"\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-01 01:39:48","session_id":"1267b782-e5a1-4334-8cf6-771d72bbc28e","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"d4678fdf-824c-4d5f-a5fe-c713d409faac\",\"member_status\":\"free\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/533.2.1 (KHTML, like Gecko) Chrome/13.0.868.0 Safari/533.2.1\",\"locale\":\"es-ES\",\"location\":\"ES\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-01 01:21:13","session_id":"2a31286e-53b4-41da-a7fd-89d966072af5","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"df8343d2-e89d-45b7-ba12-988734efcc56\",\"member_status\":\"free\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/4.0)\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://www.bing.com/\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-01 00:11:43","session_id":"2a31286e-53b4-41da-a7fd-89d966072af5","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"df8343d2-e89d-45b7-ba12-988734efcc56\",\"member_status\":\"free\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/4.0)\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-02 01:19:45","session_id":"f253b9b7-0a1a-4168-8fcf-b20a1668ce4d","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"65bacac2-8122-4ed0-a11f-ac52aa82beb0\",\"member_status\":\"paid\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (Windows NT 5.3; Win64; x64; rv:11.6) Gecko/20100101 Firefox/11.6.2\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://www.google.com/\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-02 00:42:56","session_id":"f253b9b7-0a1a-4168-8fcf-b20a1668ce4d","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"65bacac2-8122-4ed0-a11f-ac52aa82beb0\",\"member_status\":\"paid\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (Windows NT 5.3; Win64; x64; rv:11.6) Gecko/20100101 Firefox/11.6.2\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-02 00:16:52","session_id":"f253b9b7-0a1a-4168-8fcf-b20a1668ce4d","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"65bacac2-8122-4ed0-a11f-ac52aa82beb0\",\"member_status\":\"paid\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (Windows NT 5.3; Win64; x64; rv:11.6) Gecko/20100101 Firefox/11.6.2\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-03 01:01:24","session_id":"9c15f99e-c8b1-4145-a073-e7f8649d2fa4","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"4c14393f-d792-403e-bbdc-aa5af3abbdd9\",\"member_status\":\"free\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (Windows NT 5.0; rv:10.7) Gecko/20100101 Firefox/10.7.1\",\"locale\":\"en-US\",\"location\":\"US\",\"referrer\":\"https://duckduckgo.com/\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-03 00:28:09","session_id":"9c15f99e-c8b1-4145-a073-e7f8649d2fa4","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"4c14393f-d792-403e-bbdc-aa5af3abbdd9\",\"member_status\":\"free\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"Mozilla/5.0 (Windows NT 5.0; rv:10.7) Gecko/20100101 Firefox/10.7.1\",\"locale\":\"en-US\",\"location\":\"US\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-03 01:41:44","session_id":"8a2461a8-91cd-4f01-b066-3de6dc946995","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"f4c738bc-7327-440c-8007-6a0b306c05e3\",\"member_status\":\"free\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.0) AppleWebKit/533.2.0 (KHTML, like Gecko) Chrome/39.0.887.0 Safari/533.2.0\",\"locale\":\"de-DE\",\"location\":\"DE\",\"referrer\":\"https://www.bing.com/\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-03 00:53:31","session_id":"8a2461a8-91cd-4f01-b066-3de6dc946995","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"f4c738bc-7327-440c-8007-6a0b306c05e3\",\"member_status\":\"free\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.0) AppleWebKit/533.2.0 (KHTML, like Gecko) Chrome/39.0.887.0 Safari/533.2.0\",\"locale\":\"de-DE\",\"location\":\"DE\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-03 00:10:19","session_id":"8a2461a8-91cd-4f01-b066-3de6dc946995","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"f4c738bc-7327-440c-8007-6a0b306c05e3\",\"member_status\":\"free\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.0) AppleWebKit/533.2.0 (KHTML, like Gecko) Chrome/39.0.887.0 Safari/533.2.0\",\"locale\":\"de-DE\",\"location\":\"DE\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-03 00:51:20","session_id":"50785df1-3232-4ff7-8495-d93e06d63f5c","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"3675e750-09bf-44c9-bc3f-b9aebac37c5d\",\"member_status\":\"paid\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (Windows NT 6.3; rv:14.7) Gecko/20100101 Firefox/14.7.1\",\"locale\":\"fr-FR\",\"location\":\"FR\",\"referrer\":\"https://search.yahoo.com/\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-03 01:34:39","session_id":"50785df1-3232-4ff7-8495-d93e06d63f5c","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"3675e750-09bf-44c9-bc3f-b9aebac37c5d\",\"member_status\":\"paid\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (Windows NT 6.3; rv:14.7) Gecko/20100101 Firefox/14.7.1\",\"locale\":\"fr-FR\",\"location\":\"FR\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-04 00:25:39","session_id":"59478d87-ce95-40fd-a081-65d1e497bcfc","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"97c79891-2ae9-4eb2-ada8-89d2a998747d\",\"member_status\":\"paid\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 6.3) AppleWebKit/531.2.2 (KHTML, like Gecko) Chrome/31.0.808.0 Safari/531.2.2\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-04 01:10:48","session_id":"a6b6c4e6-19e3-47a9-afc6-d9870592652e","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/533.0.1 (KHTML, like Gecko) Chrome/32.0.856.0 Safari/533.0.1\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-04 00:16:10","session_id":"a6b6c4e6-19e3-47a9-afc6-d9870592652e","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/533.0.1 (KHTML, like Gecko) Chrome/32.0.856.0 Safari/533.0.1\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-04 00:00:15","session_id":"a6b6c4e6-19e3-47a9-afc6-d9870592652e","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/533.0.1 (KHTML, like Gecko) Chrome/32.0.856.0 Safari/533.0.1\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-04 01:35:41","session_id":"e22a7f6f-28da-4715-a199-6f0338b593d4","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"5369031a-a5cd-4176-83d8-d6ffcb3bcfb8\",\"member_status\":\"free\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 6.1) AppleWebKit/538.0.1 (KHTML, like Gecko) Chrome/16.0.814.0 Safari/538.0.1\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-04 00:34:33","session_id":"e22a7f6f-28da-4715-a199-6f0338b593d4","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"5369031a-a5cd-4176-83d8-d6ffcb3bcfb8\",\"member_status\":\"free\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 6.1) AppleWebKit/538.0.1 (KHTML, like Gecko) Chrome/16.0.814.0 Safari/538.0.1\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-04 01:54:50","session_id":"e22a7f6f-28da-4715-a199-6f0338b593d4","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"5369031a-a5cd-4176-83d8-d6ffcb3bcfb8\",\"member_status\":\"free\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 6.1) AppleWebKit/538.0.1 (KHTML, like Gecko) Chrome/16.0.814.0 Safari/538.0.1\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-05 01:59:00","session_id":"d8e4622f-95cc-4fba-b31b-f38ff72e0975","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"75a190eb-62da-46d2-972d-a9763c954f42\",\"member_status\":\"paid\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/3.0)\",\"locale\":\"es-ES\",\"location\":\"ES\",\"referrer\":\"\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-05 01:54:03","session_id":"d8e4622f-95cc-4fba-b31b-f38ff72e0975","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"75a190eb-62da-46d2-972d-a9763c954f42\",\"member_status\":\"paid\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/3.0)\",\"locale\":\"es-ES\",\"location\":\"ES\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-05 00:29:59","session_id":"490475f1-1fb7-4672-9edd-daa1b411b5f9","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.1) AppleWebKit/532.2.0 (KHTML, like Gecko) Chrome/20.0.898.0 Safari/532.2.0\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://www.baidu.com/\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-05 00:47:42","session_id":"490475f1-1fb7-4672-9edd-daa1b411b5f9","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"undefined\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.1) AppleWebKit/532.2.0 (KHTML, like Gecko) Chrome/20.0.898.0 Safari/532.2.0\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/\",\"href\":\"https://my-ghost-site.com/\"}"}
|
||||
{"timestamp":"2100-01-05 00:38:12","session_id":"490475f1-1fb7-4672-9edd-daa1b411b5f9","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.1) AppleWebKit/532.2.0 (KHTML, like Gecko) Chrome/20.0.898.0 Safari/532.2.0\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-06 00:51:26","session_id":"8d975128-2027-40c6-834a-972cc0293d21","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"b7e0fca6-27ce-46c0-af57-c591f20dcd51\",\"member_status\":\"free\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_7 rv:2.0; KW) AppleWebKit/537.0.1 (KHTML, like Gecko) Version/5.0.10 Safari/537.0.1\",\"locale\":\"fr-FR\",\"location\":\"FR\",\"referrer\":\"\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-06 01:28:38","session_id":"61a2896b-7cf8-4853-86a6-a0e4f87c1e21","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"6b8635fb-292f-4422-9fe4-d76cfab2ba31\",\"user-agent\":\"Mozilla/5.0 (Windows; U; Windows NT 5.1) AppleWebKit/533.1.0 (KHTML, like Gecko) Chrome/18.0.852.0 Safari/533.1.0\",\"locale\":\"en-GB\",\"location\":\"GB\",\"referrer\":\"https://search.yahoo.com/\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
||||
{"timestamp":"2100-01-07 01:44:10","session_id":"7f1e88e1-da8e-46df-bc69-d04fb29d603d","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1fc\",\"user-agent\":\"Mozilla/5.0 (Windows NT 5.0; WOW64; rv:13.9) Gecko/20100101 Firefox/13.9.7\",\"locale\":\"en-US\",\"location\":\"US\",\"referrer\":\"http://wilted-tick.com\",\"pathname\":\"/about/\",\"href\":\"https://my-ghost-site.com/about/\"}"}
|
||||
{"timestamp":"2100-01-07 02:23:19","session_id":"98159299-8111-4dc8-9156-bb339fe9508c","action":"page_hit","version":"1","payload":"{\"site_uuid\":\"mock_site_uuid\",\"member_uuid\":\"undefined\",\"member_status\":\"undefined\",\"post_uuid\":\"06b1b0c9-fb53-4a15-a060-3db3fde7b1dd\",\"user-agent\":\"Mozilla/5.0 (Windows NT 5.0; WOW64; rv:13.9) Gecko/20100101 Firefox/13.9.7\",\"locale\":\"en-US\",\"location\":\"US\",\"referrer\":\"https://my-ghost-site.com\",\"pathname\":\"/blog/hello-world/\",\"href\":\"https://my-ghost-site.com/blog/hello-world/\"}"}
|
@ -62,7 +62,6 @@ SQL >
|
||||
)
|
||||
) as date
|
||||
{% end %}
|
||||
where date <= now()
|
||||
|
||||
NODE pageviews
|
||||
DESCRIPTION >
|
||||
|
17
ghost/tinybird/scripts/branch_and_test.sh
Executable file
17
ghost/tinybird/scripts/branch_and_test.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Get the directory where this script is located
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
# Create a branch and test it
|
||||
|
||||
## Create a variable with a timestamp to use as a random name for the branch
|
||||
BRANCH_NAME="TEST_$(date +%s)"
|
||||
|
||||
tb branch create $BRANCH_NAME
|
||||
|
||||
# Run the scripts using their full paths
|
||||
"$SCRIPT_DIR/append_fixtures.sh"
|
||||
"$SCRIPT_DIR/exec_test.sh"
|
||||
|
||||
tb branch rm $BRANCH_NAME --yes
|
@ -1,9 +1,48 @@
|
||||
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
set -euo pipefail
|
||||
|
||||
export TB_VERSION_WARNING=0
|
||||
|
||||
# Get the expected count once, outside of any function
|
||||
ndjson_file="./datasources/fixtures/analytics_events.ndjson"
|
||||
export expected_count=$(wc -l < "$ndjson_file" || echo "0")
|
||||
|
||||
check_sum() {
|
||||
local file=$1
|
||||
local expected_count=$2
|
||||
|
||||
# Only perform the check if the file starts with "all_"
|
||||
if [[ ! $(basename "$file") =~ ^all_ ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local sum=0
|
||||
local column_name=""
|
||||
|
||||
# Determine if the file has a 'pageviews' column
|
||||
if head -n1 "$file" | grep -q 'pageviews'; then
|
||||
column_name="pageviews"
|
||||
else
|
||||
echo "No 'pageviews' column found in $file"
|
||||
return 0 # No relevant column found, skip the check
|
||||
fi
|
||||
|
||||
# Get the column number
|
||||
local column_num=$(head -n1 "$file" | tr ',' '\n' | grep -n "$column_name" | cut -d: -f1)
|
||||
|
||||
# Sum the values in the column
|
||||
sum=$(tail -n +2 "$file" | cut -d',' -f"$column_num" | awk '{s+=$1} END {print s}')
|
||||
|
||||
# Check if the sum equals the number of lines in the NDJSON file
|
||||
if [ "$sum" -eq "$expected_count" ]; then
|
||||
echo "✅ Sanity check passed: Sum of $column_name is $sum (matches NDJSON line count)"
|
||||
return 0
|
||||
else
|
||||
echo "🚨 Sanity check failed: Sum of $column_name is $sum, expected $expected_count (NDJSON line count)"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_test() {
|
||||
t=$1
|
||||
echo "** Running $t **"
|
||||
@ -15,7 +54,7 @@ run_test() {
|
||||
# When appending fixtures, we need to retry in case of the data is not replicated in time
|
||||
while [ $retries -lt $TOTAL_RETRIES ]; do
|
||||
# Run the test and store the output in a temporary file
|
||||
bash $t $2 >$tmpfile
|
||||
bash $t >$tmpfile
|
||||
exit_code=$?
|
||||
if [ "$exit_code" -eq 0 ]; then
|
||||
# If the test passed, break the loop
|
||||
@ -33,6 +72,7 @@ run_test() {
|
||||
|
||||
if diff -B ${t}.result $tmpfile >/dev/null 2>&1; then
|
||||
echo "✅ Test $t passed"
|
||||
check_sum ${t}.result $expected_count || return 1
|
||||
rm $tmpfile
|
||||
return 0
|
||||
elif [ $retries -eq $TOTAL_RETRIES ]; then
|
||||
@ -49,10 +89,26 @@ run_test() {
|
||||
echo ""
|
||||
}
|
||||
export -f run_test
|
||||
export -f check_sum
|
||||
|
||||
fail=0
|
||||
find ./tests -name "*.test" -print0 | xargs -0 -I {} -P 4 bash -c 'run_test "$@"' _ {} || fail=1
|
||||
|
||||
# Check if a test name was provided as an argument
|
||||
if [ $# -eq 1 ]; then
|
||||
test_name=$1
|
||||
# Find the test file that matches the provided name
|
||||
test_file=$(find ./tests -name "${test_name}*.test")
|
||||
if [ -n "$test_file" ]; then
|
||||
run_test "$test_file" || fail=1
|
||||
else
|
||||
echo "🚨 ERROR: No test found matching name: $test_name"
|
||||
fail=1
|
||||
fi
|
||||
else
|
||||
# If no test name provided, run all tests
|
||||
find ./tests -name "*.test" -print0 | xargs -0 -I {} bash -c 'run_test "$@"' _ {} || fail=1
|
||||
fi
|
||||
|
||||
if [ $fail == 1 ]; then
|
||||
exit -1;
|
||||
exit 1
|
||||
fi
|
||||
|
32
ghost/tinybird/scripts/gen_test_results.sh
Executable file
32
ghost/tinybird/scripts/gen_test_results.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Directory containing the test files
|
||||
TEST_DIR="./tests"
|
||||
|
||||
# Function to execute a test and update its result file
|
||||
execute_and_update() {
|
||||
local test_file="$1"
|
||||
local result_file="${test_file%.test}.test.result"
|
||||
|
||||
echo "Executing test: $test_file"
|
||||
|
||||
# Execute the test command and capture the output
|
||||
output=$(bash "$test_file")
|
||||
|
||||
# Write the output to the result file, overwriting existing content
|
||||
echo "$output" > "$result_file"
|
||||
|
||||
echo "Updated result file: $result_file"
|
||||
echo "------------------------"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
echo "Starting test result regeneration..."
|
||||
|
||||
# Find all .test files and process them
|
||||
find "$TEST_DIR" -name "*.test" -type f | while read -r test_file; do
|
||||
execute_and_update "$test_file"
|
||||
done
|
||||
|
||||
echo "Test result regeneration complete."
|
1
ghost/tinybird/tests/all_analytics_hits.test
Normal file
1
ghost/tinybird/tests/all_analytics_hits.test
Normal file
@ -0,0 +1 @@
|
||||
tb pipe data analytics_hits --format CSV
|
32
ghost/tinybird/tests/all_analytics_hits.test.result
Normal file
32
ghost/tinybird/tests/all_analytics_hits.test.result
Normal file
@ -0,0 +1,32 @@
|
||||
"site_uuid","timestamp","action","version","session_id","member_uuid","member_status","post_uuid","location","source","pathname","href","device","browser"
|
||||
"mock_site_uuid","2100-01-01 00:11:43","page_hit","1","2a31286e-53b4-41da-a7fd-89d966072af5","df8343d2-e89d-45b7-ba12-988734efcc56","free","undefined","GB","my-ghost-site.com","/","https://my-ghost-site.com/","desktop","ie"
|
||||
"mock_site_uuid","2100-01-01 00:51:17","page_hit","1","1267b782-e5a1-4334-8cf6-771d72bbc28e","d4678fdf-824c-4d5f-a5fe-c713d409faac","free","undefined","ES","","/","https://my-ghost-site.com/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-01 01:06:15","page_hit","1","e5c37e25-ed9e-4940-a2be-bc49149d991a","undefined","undefined","6b8635fb-292f-4422-9fe4-d76cfab2ba31","GB","petty-queen.com","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","bot","Unknown"
|
||||
"mock_site_uuid","2100-01-01 01:21:13","page_hit","1","2a31286e-53b4-41da-a7fd-89d966072af5","df8343d2-e89d-45b7-ba12-988734efcc56","free","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","GB","bing.com","/about/","https://my-ghost-site.com/about/","desktop","ie"
|
||||
"mock_site_uuid","2100-01-01 01:39:48","page_hit","1","1267b782-e5a1-4334-8cf6-771d72bbc28e","d4678fdf-824c-4d5f-a5fe-c713d409faac","free","undefined","ES","my-ghost-site.com","/","https://my-ghost-site.com/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-02 00:16:52","page_hit","1","f253b9b7-0a1a-4168-8fcf-b20a1668ce4d","65bacac2-8122-4ed0-a11f-ac52aa82beb0","paid","undefined","GB","my-ghost-site.com","/","https://my-ghost-site.com/","desktop","firefox"
|
||||
"mock_site_uuid","2100-01-02 00:42:56","page_hit","1","f253b9b7-0a1a-4168-8fcf-b20a1668ce4d","65bacac2-8122-4ed0-a11f-ac52aa82beb0","paid","undefined","GB","my-ghost-site.com","/","https://my-ghost-site.com/","desktop","firefox"
|
||||
"mock_site_uuid","2100-01-02 01:19:45","page_hit","1","f253b9b7-0a1a-4168-8fcf-b20a1668ce4d","65bacac2-8122-4ed0-a11f-ac52aa82beb0","paid","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","GB","google.com","/about/","https://my-ghost-site.com/about/","desktop","firefox"
|
||||
"mock_site_uuid","2100-01-03 00:10:19","page_hit","1","8a2461a8-91cd-4f01-b066-3de6dc946995","f4c738bc-7327-440c-8007-6a0b306c05e3","free","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","DE","my-ghost-site.com","/about/","https://my-ghost-site.com/about/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-03 00:28:09","page_hit","1","9c15f99e-c8b1-4145-a073-e7f8649d2fa4","4c14393f-d792-403e-bbdc-aa5af3abbdd9","free","6b8635fb-292f-4422-9fe4-d76cfab2ba31","US","my-ghost-site.com","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","firefox"
|
||||
"mock_site_uuid","2100-01-03 00:51:20","page_hit","1","50785df1-3232-4ff7-8495-d93e06d63f5c","3675e750-09bf-44c9-bc3f-b9aebac37c5d","paid","undefined","FR","search.yahoo.com","/","https://my-ghost-site.com/","desktop","firefox"
|
||||
"mock_site_uuid","2100-01-03 00:53:31","page_hit","1","8a2461a8-91cd-4f01-b066-3de6dc946995","f4c738bc-7327-440c-8007-6a0b306c05e3","free","6b8635fb-292f-4422-9fe4-d76cfab2ba31","DE","my-ghost-site.com","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-03 01:01:24","page_hit","1","9c15f99e-c8b1-4145-a073-e7f8649d2fa4","4c14393f-d792-403e-bbdc-aa5af3abbdd9","free","undefined","US","duckduckgo.com","/","https://my-ghost-site.com/","desktop","firefox"
|
||||
"mock_site_uuid","2100-01-03 01:34:39","page_hit","1","50785df1-3232-4ff7-8495-d93e06d63f5c","3675e750-09bf-44c9-bc3f-b9aebac37c5d","paid","undefined","FR","my-ghost-site.com","/","https://my-ghost-site.com/","desktop","firefox"
|
||||
"mock_site_uuid","2100-01-03 01:41:44","page_hit","1","8a2461a8-91cd-4f01-b066-3de6dc946995","f4c738bc-7327-440c-8007-6a0b306c05e3","free","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","DE","bing.com","/about/","https://my-ghost-site.com/about/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-04 00:00:15","page_hit","1","a6b6c4e6-19e3-47a9-afc6-d9870592652e","undefined","undefined","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","GB","my-ghost-site.com","/about/","https://my-ghost-site.com/about/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-04 00:16:10","page_hit","1","a6b6c4e6-19e3-47a9-afc6-d9870592652e","undefined","undefined","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","GB","my-ghost-site.com","/about/","https://my-ghost-site.com/about/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-04 00:25:39","page_hit","1","59478d87-ce95-40fd-a081-65d1e497bcfc","97c79891-2ae9-4eb2-ada8-89d2a998747d","paid","6b8635fb-292f-4422-9fe4-d76cfab2ba31","GB","","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-04 00:34:33","page_hit","1","e22a7f6f-28da-4715-a199-6f0338b593d4","5369031a-a5cd-4176-83d8-d6ffcb3bcfb8","free","undefined","GB","my-ghost-site.com","/","https://my-ghost-site.com/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-04 01:10:48","page_hit","1","a6b6c4e6-19e3-47a9-afc6-d9870592652e","undefined","undefined","6b8635fb-292f-4422-9fe4-d76cfab2ba31","GB","","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-04 01:35:41","page_hit","1","e22a7f6f-28da-4715-a199-6f0338b593d4","5369031a-a5cd-4176-83d8-d6ffcb3bcfb8","free","6b8635fb-292f-4422-9fe4-d76cfab2ba31","GB","","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-04 01:54:50","page_hit","1","e22a7f6f-28da-4715-a199-6f0338b593d4","5369031a-a5cd-4176-83d8-d6ffcb3bcfb8","free","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","GB","my-ghost-site.com","/about/","https://my-ghost-site.com/about/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-05 00:29:59","page_hit","1","490475f1-1fb7-4672-9edd-daa1b411b5f9","undefined","undefined","6b8635fb-292f-4422-9fe4-d76cfab2ba31","GB","baidu.com","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-05 00:38:12","page_hit","1","490475f1-1fb7-4672-9edd-daa1b411b5f9","undefined","undefined","6b8635fb-292f-4422-9fe4-d76cfab2ba31","GB","my-ghost-site.com","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-05 00:47:42","page_hit","1","490475f1-1fb7-4672-9edd-daa1b411b5f9","undefined","undefined","undefined","GB","my-ghost-site.com","/","https://my-ghost-site.com/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-05 01:54:03","page_hit","1","d8e4622f-95cc-4fba-b31b-f38ff72e0975","75a190eb-62da-46d2-972d-a9763c954f42","paid","6b8635fb-292f-4422-9fe4-d76cfab2ba31","ES","my-ghost-site.com","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","ie"
|
||||
"mock_site_uuid","2100-01-05 01:59:00","page_hit","1","d8e4622f-95cc-4fba-b31b-f38ff72e0975","75a190eb-62da-46d2-972d-a9763c954f42","paid","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","ES","","/about/","https://my-ghost-site.com/about/","desktop","ie"
|
||||
"mock_site_uuid","2100-01-06 00:51:26","page_hit","1","8d975128-2027-40c6-834a-972cc0293d21","b7e0fca6-27ce-46c0-af57-c591f20dcd51","free","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","FR","","/about/","https://my-ghost-site.com/about/","desktop","safari"
|
||||
"mock_site_uuid","2100-01-06 01:28:38","page_hit","1","61a2896b-7cf8-4853-86a6-a0e4f87c1e21","undefined","undefined","6b8635fb-292f-4422-9fe4-d76cfab2ba31","GB","search.yahoo.com","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","chrome"
|
||||
"mock_site_uuid","2100-01-07 01:44:10","page_hit","1","7f1e88e1-da8e-46df-bc69-d04fb29d603d","undefined","undefined","06b1b0c9-fb53-4a15-a060-3db3fde7b1fc","US","wilted-tick.com","/about/","https://my-ghost-site.com/about/","desktop","firefox"
|
||||
"mock_site_uuid","2100-01-07 02:23:19","page_hit","1","98159299-8111-4dc8-9156-bb339fe9508c","undefined","undefined","06b1b0c9-fb53-4a15-a060-3db3fde7b1dd","US","my-ghost-site.com","/blog/hello-world/","https://my-ghost-site.com/blog/hello-world/","desktop","firefox"
|
1
ghost/tinybird/tests/all_kpis.test
Normal file
1
ghost/tinybird/tests/all_kpis.test
Normal file
@ -0,0 +1 @@
|
||||
tb pipe data kpis --date_from 2100-01-01 --date_to 2100-01-07 --site_uuid mock_site_uuid --format CSV
|
8
ghost/tinybird/tests/all_kpis.test.result
Normal file
8
ghost/tinybird/tests/all_kpis.test.result
Normal file
@ -0,0 +1,8 @@
|
||||
"date","visits","pageviews","bounce_rate","avg_session_sec"
|
||||
"2100-01-01",3,5,0.3333333333333333,7081
|
||||
"2100-01-02",1,3,0,3773
|
||||
"2100-01-03",3,7,0,10079
|
||||
"2100-01-04",3,7,0.3333333333333333,9050
|
||||
"2100-01-05",2,5,0,1360
|
||||
"2100-01-06",2,2,1,0
|
||||
"2100-01-07",2,2,1,0
|
1
ghost/tinybird/tests/all_top_browsers.test
Normal file
1
ghost/tinybird/tests/all_top_browsers.test
Normal file
@ -0,0 +1 @@
|
||||
tb pipe data top_browsers --date_from 2100-01-01 --date_to 2100-01-07 --site_uuid mock_site_uuid --format CSV
|
6
ghost/tinybird/tests/all_top_browsers.test.result
Normal file
6
ghost/tinybird/tests/all_top_browsers.test.result
Normal file
@ -0,0 +1,6 @@
|
||||
"browser","visits","pageviews"
|
||||
"chrome",7,7
|
||||
"firefox",4,4
|
||||
"ie",2,2
|
||||
"safari",1,1
|
||||
"Unknown",1,1
|
2
ghost/tinybird/tests/all_top_devices.test
Normal file
2
ghost/tinybird/tests/all_top_devices.test
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
tb pipe data top_devices --date_from 2100-01-01 --date_to 2100-01-07 --site_uuid mock_site_uuid --format CSV
|
3
ghost/tinybird/tests/all_top_devices.test.result
Normal file
3
ghost/tinybird/tests/all_top_devices.test.result
Normal file
@ -0,0 +1,3 @@
|
||||
"device","visits","pageviews"
|
||||
"desktop",14,14
|
||||
"bot",1,1
|
2
ghost/tinybird/tests/all_top_locations.test
Normal file
2
ghost/tinybird/tests/all_top_locations.test
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
tb pipe data top_locations --date_from 2100-01-01 --date_to 2100-01-07 --site_uuid mock_site_uuid --format CSV
|
6
ghost/tinybird/tests/all_top_locations.test.result
Normal file
6
ghost/tinybird/tests/all_top_locations.test.result
Normal file
@ -0,0 +1,6 @@
|
||||
"location","visits","pageviews"
|
||||
"GB",8,17
|
||||
"US",3,4
|
||||
"FR",2,3
|
||||
"ES",2,4
|
||||
"DE",1,3
|
1
ghost/tinybird/tests/all_top_pages.test
Normal file
1
ghost/tinybird/tests/all_top_pages.test
Normal file
@ -0,0 +1 @@
|
||||
tb pipe data top_pages --date_from 2100-01-01 --date_to 2100-01-07 --site_uuid mock_site_uuid --format CSV
|
4
ghost/tinybird/tests/all_top_pages.test.result
Normal file
4
ghost/tinybird/tests/all_top_pages.test.result
Normal file
@ -0,0 +1,4 @@
|
||||
"pathname","visits","pageviews"
|
||||
"/blog/hello-world/",10,11
|
||||
"/about/",8,10
|
||||
"/",7,10
|
1
ghost/tinybird/tests/all_top_sources.test
Normal file
1
ghost/tinybird/tests/all_top_sources.test
Normal file
@ -0,0 +1 @@
|
||||
tb pipe data top_sources --date_from 2100-01-01 --date_to 2100-01-07 --site_uuid mock_site_uuid --format CSV
|
9
ghost/tinybird/tests/all_top_sources.test.result
Normal file
9
ghost/tinybird/tests/all_top_sources.test.result
Normal file
@ -0,0 +1,9 @@
|
||||
"source","visits","pageviews"
|
||||
"",6,6
|
||||
"bing.com",2,2
|
||||
"search.yahoo.com",2,2
|
||||
"google.com",1,1
|
||||
"baidu.com",1,1
|
||||
"wilted-tick.com",1,1
|
||||
"duckduckgo.com",1,1
|
||||
"petty-queen.com",1,1
|
Loading…
Reference in New Issue
Block a user