@malloydata/malloy-tests 0.0.313 → 0.0.315

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.
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.313",
25
- "@malloydata/db-duckdb": "0.0.313",
26
- "@malloydata/db-postgres": "0.0.313",
27
- "@malloydata/db-snowflake": "0.0.313",
28
- "@malloydata/db-trino": "0.0.313",
29
- "@malloydata/malloy": "0.0.313",
30
- "@malloydata/malloy-tag": "0.0.313",
31
- "@malloydata/render": "0.0.313",
24
+ "@malloydata/db-bigquery": "0.0.315",
25
+ "@malloydata/db-duckdb": "0.0.315",
26
+ "@malloydata/db-postgres": "0.0.315",
27
+ "@malloydata/db-snowflake": "0.0.315",
28
+ "@malloydata/db-trino": "0.0.315",
29
+ "@malloydata/malloy": "0.0.315",
30
+ "@malloydata/malloy-tag": "0.0.315",
31
+ "@malloydata/render": "0.0.315",
32
32
  "events": "^3.3.0",
33
33
  "jsdom": "^22.1.0",
34
34
  "luxon": "^2.4.0",
@@ -38,5 +38,5 @@
38
38
  "@types/jsdom": "^21.1.1",
39
39
  "@types/luxon": "^2.4.0"
40
40
  },
41
- "version": "0.0.313"
41
+ "version": "0.0.315"
42
42
  }
@@ -11,15 +11,37 @@ mkdir .tmp
11
11
  SCRIPTDIR=$(cd $(dirname $0); pwd)
12
12
  DATADIR=$(dirname $SCRIPTDIR)/data/postgres
13
13
 
14
- // set these in your enviornment
15
- export PGHOST=localhost
16
- export PGPORT=5432
17
- export PGUSER=root
18
- export PGPASSWORD=postgres
14
+ # Verify required environment variables and show export commands for any that are wrong
15
+ EXPORTS=""
16
+
17
+ if [ -z "$PGHOST" ] || [ "$PGHOST" != "localhost" ]; then
18
+ EXPORTS="${EXPORTS}export PGHOST=localhost\n"
19
+ fi
20
+
21
+ if [ -z "$PGPORT" ] || [ "$PGPORT" != "5432" ]; then
22
+ EXPORTS="${EXPORTS}export PGPORT=5432\n"
23
+ fi
24
+
25
+ if [ -z "$PGUSER" ] || [ "$PGUSER" != "root" ]; then
26
+ EXPORTS="${EXPORTS}export PGUSER=root\n"
27
+ fi
28
+
29
+ if [ -z "$PGPASSWORD" ] || [ "$PGPASSWORD" != "postgres" ]; then
30
+ EXPORTS="${EXPORTS}export PGPASSWORD=postgres\n"
31
+ fi
32
+
33
+ if [ -n "$EXPORTS" ]; then
34
+ echo "Required environment variables are missing or incorrect."
35
+ echo "Run these commands in your current shell or add them to your shell startup file (~/.bashrc, ~/.zshrc, etc.):"
36
+ echo ""
37
+ echo -e "$EXPORTS"
38
+ exit 1
39
+ fi
19
40
 
20
41
  docker run -p 5432:5432 -d -v $DATADIR:/init_data \
21
42
  --name postgres-malloy \
22
43
  -e POSTGRES_USER=root -e POSTGRES_PASSWORD=postgres \
44
+ -e TZ=UTC \
23
45
  --health-cmd pg_isready \
24
46
  --health-interval 10s \
25
47
  --health-timeout 5s \
@@ -36,6 +58,9 @@ done
36
58
 
37
59
  echo "Container $CONTAINER_NAME is now healthy!"
38
60
 
61
+ echo "Loading data ..."
39
62
  # configure
40
63
  echo CREATE EXTENSION tsm_system_rows\; | psql
41
64
  gunzip -c ${DATADIR}/malloytest-postgres.sql.gz | psql
65
+
66
+ echo "Ready"
@@ -713,6 +713,22 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
713
713
  ).malloyResultMatches(runtime, {mex_day: mex_19.toJSDate()});
714
714
  });
715
715
 
716
+ test.when(
717
+ !brokenIn('trino', dbName) && !brokenIn('presto', dbName) /* mtoy */
718
+ )('truncate week', async () => {
719
+ // the 19th in mexico is a wednesday, so trunc to the 15th
720
+ const mex_19 = LuxonDateTime.fromISO('2020-02-19T00:00:00', {zone});
721
+ // Find the sunday before then
722
+ const mex_sunday = mex_19.minus({days: mex_19.weekday % 7});
723
+ await expect(
724
+ `run: ${dbName}.sql("SELECT 1 as x") -> {
725
+ timezone: '${zone}'
726
+ extend: { dimension: utc_midnight is @2020-02-20 00:00:00[UTC] }
727
+ select: mex_week is utc_midnight.week
728
+ }`
729
+ ).malloyResultMatches(runtime, {mex_week: mex_sunday.toJSDate()});
730
+ });
731
+
716
732
  test.when(
717
733
  !brokenIn('trino', dbName) && !brokenIn('presto', dbName) /* mtoy */
718
734
  )('cast timestamp to date', async () => {