- 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.
27 lines
770 B
Go
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)
|
|
}
|
|
}
|