package smartconfig import ( "os" "strings" "testing" ) func TestCLIMissingEnvInterpolation(t *testing.T) { // Don't set TEST_APP_NAME - it should cause an error // Set TEST_PORT to verify partial interpolation works _ = os.Setenv("TEST_PORT", "3000") defer func() { _ = os.Unsetenv("TEST_PORT") }() // Test YAML content with missing env var yamlContent := `name: ${ENV:TEST_APP_NAME} port: ${ENV:TEST_PORT} host: localhost` // Create config from reader - should fail due to missing TEST_APP_NAME reader := strings.NewReader(yamlContent) _, err := NewFromReader(reader) if err == nil { t.Fatal("Expected error when environment variable is missing, but got none") } if !strings.Contains(err.Error(), "TEST_APP_NAME") { t.Errorf("Expected error to mention missing TEST_APP_NAME, got: %v", err) } }