[PR #241] [MERGED] test: add unit tests for langfuse helpers package #262

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/241
Author: @mason5052
Created: 4/8/2026
Status: Merged
Merged: 4/8/2026
Merged by: @asdek

Base: mainHead: test/langfuse-helpers-coverage


📝 Commits (2)

  • cad6b01 test: add unit tests for langfuse helpers package
  • 161b122 test: add getCurrentTimeRef test and strengthen ModelParameters assertions

📊 Changes

1 file changed (+533 additions, -0 deletions)

View changed files

backend/pkg/observability/langfuse/helpers_test.go (+533 -0)

📄 Description

Summary

  • Add comprehensive unit tests for all utility functions in the langfuse helpers.go package
  • Covers mergeMaps, ObservationLevel, GenerationUsageUnit, GenerationUsage, ModelParameters, GetLangchainModelParameters, trace/span ID generation, time helpers, and pointer helpers
  • All table-driven tests with t.Parallel() and tt := tt loop variable shadowing

Test Coverage

Test Function Target Cases
TestMergeMaps mergeMaps() 6 cases + mutation check
TestObservationLevel_ToLangfuse ObservationLevel.ToLangfuse() 5 levels
TestGenerationUsageUnit_String GenerationUsageUnit.String() 7 enum values
TestGenerationUsageUnit_ToLangfuse GenerationUsageUnit.ToLangfuse() valid + unknown
TestGenerationUsage_ToLangfuse GenerationUsage.ToLangfuse() nil, no costs, input/output/both costs
TestModelParameters_ToLangfuse ModelParameters.ToLangfuse() nil, empty, specific fields, all fields
TestGetLangchainModelParameters GetLangchainModelParameters() nil, empty, temperature, max tokens
TestNewTraceID newTraceID() format (32 hex) + uniqueness
TestNewSpanID newSpanID() format (16 hex) + uniqueness
TestTime* getCurrentTime, getCurrentTimeString, getTimeRef, getTimeRefString UTC, format, nil/non-nil
TestPointer* getStringRef, getIntRef, getBoolRef empty/non-empty, values

Test Plan

  • go test ./pkg/observability/langfuse/... -v -count=1 passes
  • go vet ./pkg/observability/langfuse/... passes
  • All tests use t.Parallel() with tt := tt loop variable shadowing
  • 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/241 **Author:** [@mason5052](https://github.com/mason5052) **Created:** 4/8/2026 **Status:** ✅ Merged **Merged:** 4/8/2026 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `main` ← **Head:** `test/langfuse-helpers-coverage` --- ### 📝 Commits (2) - [`cad6b01`](https://github.com/vxcontrol/pentagi/commit/cad6b01ebb11d077a198d40738dca4386197a112) test: add unit tests for langfuse helpers package - [`161b122`](https://github.com/vxcontrol/pentagi/commit/161b122d91470f7185cf8c6a7b46b9afbce7b748) test: add getCurrentTimeRef test and strengthen ModelParameters assertions ### 📊 Changes **1 file changed** (+533 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/pkg/observability/langfuse/helpers_test.go` (+533 -0) </details> ### 📄 Description ## Summary - Add comprehensive unit tests for all utility functions in the langfuse `helpers.go` package - Covers `mergeMaps`, `ObservationLevel`, `GenerationUsageUnit`, `GenerationUsage`, `ModelParameters`, `GetLangchainModelParameters`, trace/span ID generation, time helpers, and pointer helpers - All table-driven tests with `t.Parallel()` and `tt := tt` loop variable shadowing ## Test Coverage | Test Function | Target | Cases | |---------------|--------|-------| | TestMergeMaps | mergeMaps() | 6 cases + mutation check | | TestObservationLevel_ToLangfuse | ObservationLevel.ToLangfuse() | 5 levels | | TestGenerationUsageUnit_String | GenerationUsageUnit.String() | 7 enum values | | TestGenerationUsageUnit_ToLangfuse | GenerationUsageUnit.ToLangfuse() | valid + unknown | | TestGenerationUsage_ToLangfuse | GenerationUsage.ToLangfuse() | nil, no costs, input/output/both costs | | TestModelParameters_ToLangfuse | ModelParameters.ToLangfuse() | nil, empty, specific fields, all fields | | TestGetLangchainModelParameters | GetLangchainModelParameters() | nil, empty, temperature, max tokens | | TestNewTraceID | newTraceID() | format (32 hex) + uniqueness | | TestNewSpanID | newSpanID() | format (16 hex) + uniqueness | | TestTime* | getCurrentTime, getCurrentTimeString, getTimeRef, getTimeRefString | UTC, format, nil/non-nil | | TestPointer* | getStringRef, getIntRef, getBoolRef | empty/non-empty, values | ## Test Plan - [x] `go test ./pkg/observability/langfuse/... -v -count=1` passes - [x] `go vet ./pkg/observability/langfuse/...` passes - [x] All tests use `t.Parallel()` with `tt := tt` loop variable shadowing - [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#262