@malloydata/malloy-tests 0.0.324 → 0.0.325

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/CONTEXT.md +122 -0
  2. package/package.json +9 -9
package/CONTEXT.md ADDED
@@ -0,0 +1,122 @@
1
+ # Test Infrastructure
2
+
3
+ This directory contains the test infrastructure for Malloy, including cross-database tests, database-specific tests, and custom testing utilities.
4
+
5
+ ## Test Organization
6
+
7
+ Tests are organized into several categories:
8
+
9
+ ### Core Tests (`test/src/core/`)
10
+ Tests for core Malloy functionality that don't require database execution:
11
+ - AST generation
12
+ - IR generation
13
+ - Model semantics
14
+ - Type checking
15
+ - Error handling
16
+
17
+ ### Database-Specific Tests (`test/src/databases/{database}/`)
18
+ Tests that verify database-specific behavior:
19
+ - `test/src/databases/bigquery/` - BigQuery-specific tests
20
+ - `test/src/databases/postgres/` - PostgreSQL-specific tests
21
+ - `test/src/databases/duckdb/` - DuckDB-specific tests
22
+ - etc.
23
+
24
+ Each database may have unique features, SQL syntax, or limitations that require specific testing.
25
+
26
+ ### Cross-Database Tests (`test/src/databases/all/`)
27
+ Tests that run against **all** supported databases to ensure consistent behavior across dialects:
28
+ - Query semantics
29
+ - Data type handling
30
+ - Function behavior
31
+ - Join operations
32
+ - Aggregations
33
+
34
+ These tests are particularly important for verifying that Malloy's abstraction works correctly across all supported SQL dialects.
35
+
36
+ ## Custom Test Utilities
37
+
38
+ ### malloyResultMatches Matcher
39
+ Custom Jest matcher for comparing query results across different databases.
40
+
41
+ **Purpose:**
42
+ Different databases may format results slightly differently (date formatting, float precision, etc.). This matcher provides fuzzy comparison that accounts for these differences while still verifying semantic correctness.
43
+
44
+ **Usage:**
45
+ ```typescript
46
+ expect(actualResult).malloyResultMatches(expectedResult);
47
+ ```
48
+
49
+ **What it handles:**
50
+ - Float precision differences
51
+ - Date/timestamp format variations
52
+ - Null vs undefined equivalence
53
+ - Result ordering (when not semantically important)
54
+
55
+ ## Database Setup
56
+
57
+ ### DuckDB
58
+ DuckDB tests require building the test database:
59
+
60
+ ```bash
61
+ npm run build-duckdb-db # Creates test/data/duckdb/duckdb_test.db
62
+ ```
63
+
64
+ This creates a local DuckDB database file populated with test data.
65
+
66
+ ### PostgreSQL, MySQL, Trino, Presto
67
+ These databases require Docker containers to be running.
68
+
69
+ **Starting database containers:**
70
+ Each database has a startup script in the test directory:
71
+ - `test/postgres/postgres_start.sh`
72
+ - `test/mysql/mysql_start.sh`
73
+ - `test/trino/trino_start.sh`
74
+ - `test/presto/presto_start.sh`
75
+
76
+ These scripts start Docker containers with appropriate test configurations and data.
77
+
78
+ ### BigQuery
79
+ BigQuery tests require:
80
+ - Valid GCP authentication
81
+ - Access to test datasets in BigQuery
82
+ - Proper environment variables set
83
+
84
+ BigQuery tests typically run only in CI environments with appropriate credentials.
85
+
86
+ ### Snowflake
87
+ Snowflake tests require:
88
+ - Valid Snowflake account and credentials
89
+ - Access to test databases
90
+ - Proper environment variables set
91
+
92
+ ## CI-Specific Test Commands
93
+
94
+ The CI system runs different test suites optimized for parallel execution:
95
+
96
+ - **`npm run ci-core`** - Core tests (no database required)
97
+ - **`npm run ci-duckdb`** - DuckDB-specific tests only
98
+ - **`npm run ci-bigquery`** - BigQuery-specific tests only
99
+ - **`npm run ci-postgres`** - PostgreSQL-specific tests only
100
+
101
+ These commands are optimized for CI and may not work correctly in local development environments.
102
+
103
+ ## Test Data
104
+
105
+ Test data is organized by database and includes:
106
+ - Schema definitions
107
+ - Sample datasets
108
+ - Expected query results
109
+ - Edge cases and error conditions
110
+
111
+ Test data should be:
112
+ - Small enough for fast test execution
113
+ - Comprehensive enough to cover important cases
114
+ - Consistent across databases (where applicable)
115
+
116
+ ## Important Notes
117
+
118
+ - Cross-database tests are critical for verifying Malloy's dialect abstraction
119
+ - Custom matchers help handle legitimate database differences
120
+ - Database setup scripts must be run before database-specific tests
121
+ - CI has access to more databases than typical development environments
122
+ - Test data should be committed to the repository (except for large binary files)
package/package.json CHANGED
@@ -21,14 +21,14 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@jest/globals": "^29.4.3",
24
- "@malloydata/db-bigquery": "0.0.324",
25
- "@malloydata/db-duckdb": "0.0.324",
26
- "@malloydata/db-postgres": "0.0.324",
27
- "@malloydata/db-snowflake": "0.0.324",
28
- "@malloydata/db-trino": "0.0.324",
29
- "@malloydata/malloy": "0.0.324",
30
- "@malloydata/malloy-tag": "0.0.324",
31
- "@malloydata/render": "0.0.324",
24
+ "@malloydata/db-bigquery": "0.0.325",
25
+ "@malloydata/db-duckdb": "0.0.325",
26
+ "@malloydata/db-postgres": "0.0.325",
27
+ "@malloydata/db-snowflake": "0.0.325",
28
+ "@malloydata/db-trino": "0.0.325",
29
+ "@malloydata/malloy": "0.0.325",
30
+ "@malloydata/malloy-tag": "0.0.325",
31
+ "@malloydata/render": "0.0.325",
32
32
  "events": "^3.3.0",
33
33
  "jsdom": "^22.1.0",
34
34
  "luxon": "^3.5.0",
@@ -38,5 +38,5 @@
38
38
  "@types/jsdom": "^21.1.1",
39
39
  "@types/luxon": "^3.5.0"
40
40
  },
41
- "version": "0.0.324"
41
+ "version": "0.0.325"
42
42
  }