Files
threshold/api/env_test.go
shadowdaoandClaude Sonnet 5.5 306960d24b Add THRESHOLD_* env var support with BOUNDARY_* fallback
Introduce api.Getenv/api.LookupEnv which prefer THRESHOLD_X and fall back to legacy BOUNDARY_X; use them for user-facing env var reads.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 09:45:44 -07:00

25 lines
695 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package api
import "testing"
func TestEnvFallback(t *testing.T) {
t.Setenv("THRESHOLD_ZZ_TEST", "")
t.Setenv("BOUNDARY_ZZ_TEST", "old")
if got := Getenv("BOUNDARY_ZZ_TEST"); got != "old" {
t.Fatalf("want old, got %q", got)
}
t.Setenv("THRESHOLD_ZZ_TEST", "new")
if got := Getenv("BOUNDARY_ZZ_TEST"); got != "new" {
t.Fatalf("want new, got %q", got)
}
if got, ok := LookupEnv("THRESHOLD_ZZ_TEST"); !ok || got != "new" {
t.Fatalf("want new, got %q %v", got, ok)
}
if PreferredEnvName("BOUNDARY_ADDR") != "THRESHOLD_ADDR" || LegacyEnvName("THRESHOLD_ADDR") != "BOUNDARY_ADDR" {
t.Fatal("name mapping")
}
}