From ab907f01d8e88ecded5e321018839b70d319985b Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 15 Apr 2026 20:11:57 -0400 Subject: [PATCH] Add indexing tests on schemas / collection id duplication Signed-off-by: Juan Cruz Viotti --- test/cli/CMakeLists.txt | 3 + .../duplicate-path-filename-matches-key.sh | 72 +++++++++++++++++ .../common/duplicate-path-id-matches-key.sh | 78 +++++++++++++++++++ ...duplicate-path-subdirectory-matches-key.sh | 77 ++++++++++++++++++ 4 files changed, 230 insertions(+) create mode 100755 test/cli/index/common/duplicate-path-filename-matches-key.sh create mode 100755 test/cli/index/common/duplicate-path-id-matches-key.sh create mode 100755 test/cli/index/common/duplicate-path-subdirectory-matches-key.sh diff --git a/test/cli/CMakeLists.txt b/test/cli/CMakeLists.txt index d646cdd61..9e9f8371f 100644 --- a/test/cli/CMakeLists.txt +++ b/test/cli/CMakeLists.txt @@ -98,6 +98,9 @@ if(ONE_INDEX) sourcemeta_one_test_cli(common index string-directory-overlap) sourcemeta_one_test_cli(common index non-existent-collection-directory) sourcemeta_one_test_cli(common index collection-path-is-file) + sourcemeta_one_test_cli(common index duplicate-path-filename-matches-key) + sourcemeta_one_test_cli(common index duplicate-path-id-matches-key) + sourcemeta_one_test_cli(common index duplicate-path-subdirectory-matches-key) sourcemeta_one_test_cli(common index rebuild-zero-to-one) sourcemeta_one_test_cli(common index rebuild-one-to-zero) sourcemeta_one_test_cli(common index resolve-schema) diff --git a/test/cli/index/common/duplicate-path-filename-matches-key.sh b/test/cli/index/common/duplicate-path-filename-matches-key.sh new file mode 100755 index 000000000..9e7f49816 --- /dev/null +++ b/test/cli/index/common/duplicate-path-filename-matches-key.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +set -o errexit +set -o nounset + +TMP="$(mktemp -d)" +clean() { rm -rf "$TMP"; } +trap clean EXIT + +mkdir -p "$TMP/schemas/foo" + +cat << 'EOF' > "$TMP/schemas/foo/foo.json" +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object" +} +EOF + +cat << EOF > "$TMP/one.json" +{ + "url": "http://localhost:8000", + "contents": { + "foo": { + "path": "./schemas/foo" + } + } +} +EOF + +"$1" "$TMP/one.json" "$TMP/output" + +cd "$TMP/output" +find . -mindepth 1 | LC_ALL=C sort > "$TMP/manifest.txt" +cd - > /dev/null + +cat << 'EOF' > "$TMP/expected.txt" +./configuration.json +./explorer +./explorer/% +./explorer/%/404.metapack +./explorer/%/directory-html.metapack +./explorer/%/directory.metapack +./explorer/%/search.metapack +./explorer/foo +./explorer/foo/% +./explorer/foo/%/directory-html.metapack +./explorer/foo/%/directory.metapack +./explorer/foo/foo +./explorer/foo/foo/% +./explorer/foo/foo/%/schema-html.metapack +./explorer/foo/foo/%/schema.metapack +./routes.bin +./schemas +./schemas/foo +./schemas/foo/foo +./schemas/foo/foo/% +./schemas/foo/foo/%/blaze-exhaustive.metapack +./schemas/foo/foo/%/blaze-fast.metapack +./schemas/foo/foo/%/bundle.metapack +./schemas/foo/foo/%/dependencies.metapack +./schemas/foo/foo/%/dependents.metapack +./schemas/foo/foo/%/editor.metapack +./schemas/foo/foo/%/health.metapack +./schemas/foo/foo/%/locations.metapack +./schemas/foo/foo/%/positions.metapack +./schemas/foo/foo/%/schema.metapack +./schemas/foo/foo/%/stats.metapack +./state.bin +./version.json +EOF + +diff "$TMP/manifest.txt" "$TMP/expected.txt" diff --git a/test/cli/index/common/duplicate-path-id-matches-key.sh b/test/cli/index/common/duplicate-path-id-matches-key.sh new file mode 100755 index 000000000..2756fb25f --- /dev/null +++ b/test/cli/index/common/duplicate-path-id-matches-key.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +set -o errexit +set -o nounset + +TMP="$(mktemp -d)" +clean() { rm -rf "$TMP"; } +trap clean EXIT + +mkdir -p "$TMP/schemas/bar" + +cat << 'EOF' > "$TMP/schemas/bar/test.json" +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "http://localhost:8000/bar/test", + "type": "string" +} +EOF + +cat << EOF > "$TMP/one.json" +{ + "url": "http://localhost:8000", + "contents": { + "bar": { + "path": "./schemas/bar" + } + } +} +EOF + +"$1" "$TMP/one.json" "$TMP/output" + +cd "$TMP/output" +find . -mindepth 1 | LC_ALL=C sort > "$TMP/manifest.txt" +cd - > /dev/null + +cat << 'EOF' > "$TMP/expected.txt" +./configuration.json +./explorer +./explorer/% +./explorer/%/404.metapack +./explorer/%/directory-html.metapack +./explorer/%/directory.metapack +./explorer/%/search.metapack +./explorer/bar +./explorer/bar/% +./explorer/bar/%/directory-html.metapack +./explorer/bar/%/directory.metapack +./explorer/bar/bar +./explorer/bar/bar/% +./explorer/bar/bar/%/directory-html.metapack +./explorer/bar/bar/%/directory.metapack +./explorer/bar/bar/test +./explorer/bar/bar/test/% +./explorer/bar/bar/test/%/schema-html.metapack +./explorer/bar/bar/test/%/schema.metapack +./routes.bin +./schemas +./schemas/bar +./schemas/bar/bar +./schemas/bar/bar/test +./schemas/bar/bar/test/% +./schemas/bar/bar/test/%/blaze-exhaustive.metapack +./schemas/bar/bar/test/%/blaze-fast.metapack +./schemas/bar/bar/test/%/bundle.metapack +./schemas/bar/bar/test/%/dependencies.metapack +./schemas/bar/bar/test/%/dependents.metapack +./schemas/bar/bar/test/%/editor.metapack +./schemas/bar/bar/test/%/health.metapack +./schemas/bar/bar/test/%/locations.metapack +./schemas/bar/bar/test/%/positions.metapack +./schemas/bar/bar/test/%/schema.metapack +./schemas/bar/bar/test/%/stats.metapack +./state.bin +./version.json +EOF + +diff "$TMP/manifest.txt" "$TMP/expected.txt" diff --git a/test/cli/index/common/duplicate-path-subdirectory-matches-key.sh b/test/cli/index/common/duplicate-path-subdirectory-matches-key.sh new file mode 100755 index 000000000..8c5a9f069 --- /dev/null +++ b/test/cli/index/common/duplicate-path-subdirectory-matches-key.sh @@ -0,0 +1,77 @@ +#!/bin/sh + +set -o errexit +set -o nounset + +TMP="$(mktemp -d)" +clean() { rm -rf "$TMP"; } +trap clean EXIT + +mkdir -p "$TMP/schemas/baz/baz" + +cat << 'EOF' > "$TMP/schemas/baz/baz/test.json" +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "array" +} +EOF + +cat << EOF > "$TMP/one.json" +{ + "url": "http://localhost:8000", + "contents": { + "baz": { + "path": "./schemas/baz" + } + } +} +EOF + +"$1" "$TMP/one.json" "$TMP/output" + +cd "$TMP/output" +find . -mindepth 1 | LC_ALL=C sort > "$TMP/manifest.txt" +cd - > /dev/null + +cat << 'EOF' > "$TMP/expected.txt" +./configuration.json +./explorer +./explorer/% +./explorer/%/404.metapack +./explorer/%/directory-html.metapack +./explorer/%/directory.metapack +./explorer/%/search.metapack +./explorer/baz +./explorer/baz/% +./explorer/baz/%/directory-html.metapack +./explorer/baz/%/directory.metapack +./explorer/baz/baz +./explorer/baz/baz/% +./explorer/baz/baz/%/directory-html.metapack +./explorer/baz/baz/%/directory.metapack +./explorer/baz/baz/test +./explorer/baz/baz/test/% +./explorer/baz/baz/test/%/schema-html.metapack +./explorer/baz/baz/test/%/schema.metapack +./routes.bin +./schemas +./schemas/baz +./schemas/baz/baz +./schemas/baz/baz/test +./schemas/baz/baz/test/% +./schemas/baz/baz/test/%/blaze-exhaustive.metapack +./schemas/baz/baz/test/%/blaze-fast.metapack +./schemas/baz/baz/test/%/bundle.metapack +./schemas/baz/baz/test/%/dependencies.metapack +./schemas/baz/baz/test/%/dependents.metapack +./schemas/baz/baz/test/%/editor.metapack +./schemas/baz/baz/test/%/health.metapack +./schemas/baz/baz/test/%/locations.metapack +./schemas/baz/baz/test/%/positions.metapack +./schemas/baz/baz/test/%/schema.metapack +./schemas/baz/baz/test/%/stats.metapack +./state.bin +./version.json +EOF + +diff "$TMP/manifest.txt" "$TMP/expected.txt"