Skip to content

Add test coverage for []T slice support and predicate= tag#9

Merged
matthewmcneely merged 6 commits intomatthewmcneely:mainfrom
mlwelles:feature/slice-and-predicate-tests
Feb 28, 2026
Merged

Add test coverage for []T slice support and predicate= tag#9
matthewmcneely merged 6 commits intomatthewmcneely:mainfrom
mlwelles:feature/slice-and-predicate-tests

Conversation

@mlwelles
Copy link

@mlwelles mlwelles commented Feb 18, 2026

Summary

Adds test coverage for existing functionality in modusGraph and dgman:

  1. Value-type slice tests (slice_test.go) — Verifies that []T (value-type) slices round-trip correctly and behave the same as []*T (pointer) slices for entity relationships. This exercises existing dgman behavior where value copies are assigned when populating non-pointer slice fields.

  2. predicate= tag e2e tests (predicate_test.go) — Comprehensive end-to-end tests for the dgraph:"predicate=<name>" struct tag, covering filters, upsert, query builder, and forward/reverse edge traversal. These tests confirm that custom predicate names work correctly across all dgman operations, decoupling Go field names and JSON keys from Dgraph predicate names.

  3. Reverse edge tests — Validates the predicate=~<name> pattern for reverse edge traversal with custom predicate names.

Dependency

The predicate_test.go tests depend on bug fixes in dgman for predicate= tag support, which have been merged:

Changes

  • slice_test.go (new): Value slice round-trip tests for string, int, float, bool slices
  • predicate_test.go (new): Full CRUD + search + query builder tests with predicate= custom names
  • go.mod / go.sum: Updated dgman to v2.2.0, removed local replace directive

Test plan

  • slice_test.go passes against live Dgraph
  • predicate_test.go passes against live Dgraph
  • go.mod updated to dgman v2.2.0 release

…te= e2e tests

- Add replace directive for github.com/dolan-in/dgman/v2 => ../dgman
  to pull in predicate= fixes from the dgman fork.

- Add slice_test.go with tests proving []T value-type slices work:
  - TestValueTypeSliceInsertAndQuery: insert/get with []Genre
  - TestPointerTypeSliceInsertAndQuery: baseline with []*Genre
  - TestValueTypeSliceParity: confirms []T and []*T produce equivalent results
  - TestValueTypeSliceUpdate: update with additional []Genre elements
  - TestValueTypeSliceEmpty: nil/empty slice handling

- Add predicate_test.go with e2e tests for predicate= tag support:
  - TestPredicateInsertAndGet: round-trip with predicate= fields
  - TestPredicateUpdate: update with predicate= fields
  - TestPredicateUpsert: upsert with predicate= (skipped, depends on dgman read fix)
  - TestPredicateQuery: filter queries using predicate names
Add unique to PredicateFilm.Title dgraph tag (required for dgman
upsert deduplication) and remove t.Skip now that the dgman fork
fixes both read and write paths for predicate= fields.
The replace github.com/dolan-in/dgman/v2 => ../dgman directive was
needed for local development with the forked dgman. Remove it for
the upstream PR since the upstream repo should use the published
dgman module.
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

mlwelles and others added 3 commits February 18, 2026 12:03
Test that forward edges (predicate=written_by) and reverse edges
(predicate=~written_by) work correctly together through Insert, Get,
and Query operations. This covers the pattern used by modusGraphGen
for entities like Film/Genre where the reverse edge is declared on
the parent entity.
Copy link
Owner

@matthewmcneely matthewmcneely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mlwelles When you say "Adds support for explicit value slices in addition to well as pointer slices"... that is not something added in the codepath of modusgraph, only in showing that it's possible by testing, right?

@mlwelles
Copy link
Author

mlwelles commented Feb 19, 2026

Sorry! IIRC, I was on a call and multitasking when I asked Claude to open and write the PR for this. It seemed such a simple one and, otherwise distracted , I didn't check the description to make sure it was correct.

@mlwelles mlwelles changed the title Add value slice support tests and predicate= tag e2e tests Add test coverage for []T slice support and predicate= tag Feb 19, 2026
@matthewmcneely matthewmcneely merged commit 5ac55b0 into matthewmcneely:main Feb 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants