Skip to content

test: add missing tests for Entity+Edge model migration#513

Merged
ravisuhag merged 3 commits intomainfrom
test/add-missing-entity-edge-tests
Mar 31, 2026
Merged

test: add missing tests for Entity+Edge model migration#513
ravisuhag merged 3 commits intomainfrom
test/add-missing-entity-edge-tests

Conversation

@ravisuhag
Copy link
Copy Markdown
Member

Summary

  • Restores test coverage lost during the Asset → Entity+Edge migration (706 lines added across 11 files)
  • Adds 4 new test files for previously untested components: enrich processor, labels processor, console sink, kafka sink
  • Strengthens 5 existing test files with edge-case coverage: models (record, util), script processor, compass sink, file sink

New test files

Component Coverage
processors/enrich Init validation, Process with nil/existing properties, edge passthrough, non-string value skip
processors/labels Init validation, Process with nil/existing labels, label merging, edge passthrough
sinks/console Init, Sink with single/multiple/empty batches, records with edges, Close
sinks/kafka Init config validation (missing brokers, missing topic, empty strings)

Strengthened tests

Component Added
models/record Multiple edges, nil entity handling
models/util Nil/empty props, nested props sanitization, JSON serialization with/without edges
processors/script Modify entity name, nil properties, edge preservation through processing
sinks/compass Empty batch handling
sinks/file Empty batch, records with edges in ndjson and yaml formats

Test plan

  • All new tests pass with go test -tags=plugins ./...
  • Full test suite passes (only pre-existing BigQuery ARM64 Docker image issue)
  • No regressions in existing tests

Restore and strengthen test coverage that was lost during the
Asset → Entity+Edge migration. Adds new test files for previously
untested components and extends existing test files with edge-case
coverage.

New test files:
- processors/enrich: Init validation, Process with nil/existing props, edge passthrough
- processors/labels: Init validation, Process with nil/existing labels, merge, edge passthrough
- sinks/console: Init, Sink single/multiple/empty/with-edges, Close
- sinks/kafka: Init config validation (missing brokers, topic, etc.)

Strengthened tests:
- models/record: multiple edges, nil entity
- models/util: nil/empty props, nested props sanitization, JSON with/without edges
- processors/script: modify entity name, nil properties, edge preservation
- sinks/compass: empty batch handling
- sinks/file: empty batch, records with edges (ndjson + yaml)
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

Warning

Rate limit exceeded

@ravisuhag has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 37 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 37 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4dddbcfe-4e14-484f-81bf-e1015be7ea26

📥 Commits

Reviewing files that changed from the base of the PR and between 669ebda and eec507f.

📒 Files selected for processing (2)
  • Makefile
  • docs/docs/concepts/context_graph.md
📝 Walkthrough

Walkthrough

This pull request expands test coverage across the models, processors, and sinks packages. It adds unit tests for core model operations including NewRecord, NewEntity, and RecordToJSON behavior with various input scenarios. New test suites are introduced for processor implementations (enrich, labels, and script processors) validating initialization and data processing logic. Complete test files are added for sink implementations (console, compass, file, and kafka sinks) covering initialization, sinking operations, and resource cleanup. Additional test fixture files in NDJSON and YAML formats support file sink testing with sample records containing edges and entities.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding missing tests for the Entity+Edge model migration, which is clearly reflected in all file summaries.
Description check ✅ Passed The description directly relates to the changeset, providing a clear overview of the 706 lines added across 11 test files and detailing new test coverage for Entity+Edge components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
plugins/sinks/file/file_test.go (1)

84-140: Consider writing outputs to t.TempDir() for better test isolation.

Using checked-in fixture paths as write targets can introduce shared mutable state between tests.

♻️ Suggested test-isolation refactor
+import "path/filepath"
...
- config := map[string]any{
-   "path":   "./test-dir/edges.ndjson",
-   "format": "ndjson",
- }
+ tmpDir := t.TempDir()
+ config := map[string]any{
+   "path":   filepath.Join(tmpDir, "edges.ndjson"),
+   "format": "ndjson",
+ }

Apply similarly to the yaml and empty-batch subtests.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/sinks/file/file_test.go` around lines 84 - 140, Tests currently write
to checked-in fixture paths which creates shared mutable state; update each
subtest ("should sink empty batch without error", "should sink records with
edges in ndjson format", "should sink records with edges in yaml format") to use
t.TempDir() and set the config["path"] to a file inside that temp dir (e.g.,
filepath.Join(tmpDir, "edges.ndjson" or "edges.yaml") ), keeping the same use of
f.New, fileSink.Init and fileSink.Sink calls; this ensures isolated writable
paths per test and removes reliance on checked-in directories.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@plugins/sinks/file/file_test.go`:
- Around line 84-140: Tests currently write to checked-in fixture paths which
creates shared mutable state; update each subtest ("should sink empty batch
without error", "should sink records with edges in ndjson format", "should sink
records with edges in yaml format") to use t.TempDir() and set the
config["path"] to a file inside that temp dir (e.g., filepath.Join(tmpDir,
"edges.ndjson" or "edges.yaml") ), keeping the same use of f.New, fileSink.Init
and fileSink.Sink calls; this ensures isolated writable paths per test and
removes reliance on checked-in directories.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4437f22e-0308-4e27-94f6-3b6a82a4ea79

📥 Commits

Reviewing files that changed from the base of the PR and between d71b46a and 669ebda.

📒 Files selected for processing (11)
  • models/record_test.go
  • models/util_test.go
  • plugins/processors/enrich/processor_test.go
  • plugins/processors/labels/labels_test.go
  • plugins/processors/script/tengo_script_test.go
  • plugins/sinks/compass/sink_test.go
  • plugins/sinks/console/sink_test.go
  • plugins/sinks/file/file_test.go
  • plugins/sinks/file/test-dir/edges.ndjson
  • plugins/sinks/file/test-dir/edges.yaml
  • plugins/sinks/kafka/sink_test.go

Replace outdated Asset terminology with the current Record/Entity/Edge
model that was introduced in the migration.
Update PROTON_COMMIT to the commit that added the new Entity+Edge
protos and removed the legacy assets. Update the --path flag from
the deleted raystack/assets/v1beta2 to raystack/meteor/v1beta1.
@ravisuhag ravisuhag merged commit 56ae808 into main Mar 31, 2026
51 checks passed
@ravisuhag ravisuhag deleted the test/add-missing-entity-edge-tests branch March 31, 2026 01:40
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.

1 participant