[PR #242] [MERGED] test: add unit tests for langfuse context and noop observer #261

Closed
opened 2026-06-06 22:09:56 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/242
Author: @mason5052
Created: 4/8/2026
Status: Merged
Merged: 4/11/2026
Merged by: @asdek

Base: mainHead: test/langfuse-context-noop-coverage


📝 Commits (2)

  • cb9e46b test: add unit tests for langfuse context and noop observer
  • 357e8af test: add edge case tests for noop observer branch coverage

📊 Changes

2 files changed (+228 additions, -0 deletions)

View changed files

backend/pkg/observability/langfuse/context_test.go (+63 -0)
backend/pkg/observability/langfuse/noop_test.go (+165 -0)

📄 Description

Summary

  • Add unit tests for context.go (observation context put/get/nesting)
  • Add unit tests for noop.go (noop observer used as default fallback when Langfuse is not configured)

Test Coverage

context_test.go (3 tests):

Test What it verifies
TestObservationContext_RoundTrip put + get returns same TraceID and ObservationID
TestGetObservationContext_NotFound empty context returns false
TestObservationContext_NestedOverride inner context overrides, outer remains unchanged

noop_test.go (9 tests):

Test What it verifies
TestNewNoopObserver_ImplementsObserver compile-time interface check
TestNoopObserver_NewObservation_NewTrace generates 32-char trace ID when no parent
TestNoopObserver_NewObservation_InheritsParentTrace child inherits parent trace ID
TestNoopObserver_NewObservation_ExplicitTraceID WithObservationTraceID overrides parent
TestNoopObserver_NewObservation_InheritsParentObservationID observation ID inherited when not set
TestNoopObserver_NewObservation_ExplicitObservationID WithObservationID overrides parent
TestNoopObserver_Shutdown returns nil
TestNoopObserver_ForceFlush returns nil
TestNoopObserver_Enqueue_NoPanic no-op with nil and non-nil events

Test Plan

  • go test ./pkg/observability/langfuse/ -v -count=1 passes (12/12 new tests)
  • go vet ./pkg/observability/langfuse/ passes
  • All tests use t.Parallel()
  • Follows existing test patterns from converter_test.go

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/242 **Author:** [@mason5052](https://github.com/mason5052) **Created:** 4/8/2026 **Status:** ✅ Merged **Merged:** 4/11/2026 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `main` ← **Head:** `test/langfuse-context-noop-coverage` --- ### 📝 Commits (2) - [`cb9e46b`](https://github.com/vxcontrol/pentagi/commit/cb9e46b64060ccbc09bf1f06fd81b522b5c54924) test: add unit tests for langfuse context and noop observer - [`357e8af`](https://github.com/vxcontrol/pentagi/commit/357e8affbb0fe9f18a0608813cc5ad812d12c97b) test: add edge case tests for noop observer branch coverage ### 📊 Changes **2 files changed** (+228 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/pkg/observability/langfuse/context_test.go` (+63 -0) ➕ `backend/pkg/observability/langfuse/noop_test.go` (+165 -0) </details> ### 📄 Description ## Summary - Add unit tests for `context.go` (observation context put/get/nesting) - Add unit tests for `noop.go` (noop observer used as default fallback when Langfuse is not configured) ## Test Coverage **context_test.go (3 tests):** | Test | What it verifies | |------|-----------------| | TestObservationContext_RoundTrip | put + get returns same TraceID and ObservationID | | TestGetObservationContext_NotFound | empty context returns false | | TestObservationContext_NestedOverride | inner context overrides, outer remains unchanged | **noop_test.go (9 tests):** | Test | What it verifies | |------|-----------------| | TestNewNoopObserver_ImplementsObserver | compile-time interface check | | TestNoopObserver_NewObservation_NewTrace | generates 32-char trace ID when no parent | | TestNoopObserver_NewObservation_InheritsParentTrace | child inherits parent trace ID | | TestNoopObserver_NewObservation_ExplicitTraceID | WithObservationTraceID overrides parent | | TestNoopObserver_NewObservation_InheritsParentObservationID | observation ID inherited when not set | | TestNoopObserver_NewObservation_ExplicitObservationID | WithObservationID overrides parent | | TestNoopObserver_Shutdown | returns nil | | TestNoopObserver_ForceFlush | returns nil | | TestNoopObserver_Enqueue_NoPanic | no-op with nil and non-nil events | ## Test Plan - [x] `go test ./pkg/observability/langfuse/ -v -count=1` passes (12/12 new tests) - [x] `go vet ./pkg/observability/langfuse/` passes - [x] All tests use `t.Parallel()` - [x] Follows existing test patterns from `converter_test.go` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:56 -04:00
yindo closed this issue 2026-06-06 22:09:56 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#261