Files
coder/codersdk/appname_internal_test.go
T
Ehab Younes da45488208 feat: attribute session counts by app family (#28337)
- Centralize app-to-family attribution in the SDK registry so recognized
app aliases contribute to their family's session counts and usage
minutes without duplicating name lists across SQL queries.
- Pass the registry into agent stats queries, insights, and usage rollups.
- Validate its structure in dbauthz so missing or renamed families fail
explicitly instead of silently producing zero counts.
- Decompose session maps once per row for per-agent sums while retaining
the key-presence checks used by insights. Update reporting consumers
and add coverage for alias attribution and registry validation.
2026-09-10 13:54:11 +02:00

27 lines
770 B
Go

package codersdk
import (
"testing"
"github.com/stretchr/testify/require"
)
// Lookups fold input through NormalizeAppName before probing, so map keys
// that are not already normalized can never match.
func TestAppNameFamilyKeysAreNormalized(t *testing.T) {
t.Parallel()
for name := range appNameFamilies {
require.Equal(t, NormalizeAppName(name), name)
}
}
// A family with no destination in attributedAppFamilies silently drops its
// sessions from usage reporting, so adding one must fail here first.
func TestEveryFamilyIsAttributed(t *testing.T) {
t.Parallel()
for appName, family := range appNameFamilies {
require.Contains(t, attributedAppFamilies, family,
"app %q maps to family %q, which usage reporting cannot report", appName, family)
}
}