remove makeRuntime facade from Env (#22523)

This commit is contained in:
Kit Langton
2026-04-15 10:55:50 -04:00
committed by GitHub
parent 685d79e953
commit fe01fa7249
3 changed files with 85 additions and 96 deletions

View File

@@ -11,6 +11,10 @@ import { Global } from "../../src/global"
import { Filesystem } from "../../src/util/filesystem"
import { Effect } from "effect"
import { AppRuntime } from "../../src/effect/app-runtime"
import { makeRuntime } from "../../src/effect/run-service"
const env = makeRuntime(Env.Service, Env.defaultLayer)
const set = (k: string, v: string) => env.runSync((svc) => svc.set(k, v))
async function list() {
return AppRuntime.runPromise(
@@ -42,8 +46,8 @@ test("Bedrock: config region takes precedence over AWS_REGION env var", async ()
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_REGION", "us-east-1")
Env.set("AWS_PROFILE", "default")
set("AWS_REGION", "us-east-1")
set("AWS_PROFILE", "default")
},
fn: async () => {
const providers = await list()
@@ -67,8 +71,8 @@ test("Bedrock: falls back to AWS_REGION env var when no config region", async ()
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_REGION", "eu-west-1")
Env.set("AWS_PROFILE", "default")
set("AWS_REGION", "eu-west-1")
set("AWS_PROFILE", "default")
},
fn: async () => {
const providers = await list()
@@ -122,9 +126,9 @@ test("Bedrock: loads when bearer token from auth.json is present", async () => {
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_PROFILE", "")
Env.set("AWS_ACCESS_KEY_ID", "")
Env.set("AWS_BEARER_TOKEN_BEDROCK", "")
set("AWS_PROFILE", "")
set("AWS_ACCESS_KEY_ID", "")
set("AWS_BEARER_TOKEN_BEDROCK", "")
},
fn: async () => {
const providers = await list()
@@ -168,8 +172,8 @@ test("Bedrock: config profile takes precedence over AWS_PROFILE env var", async
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_PROFILE", "default")
Env.set("AWS_ACCESS_KEY_ID", "test-key-id")
set("AWS_PROFILE", "default")
set("AWS_ACCESS_KEY_ID", "test-key-id")
},
fn: async () => {
const providers = await list()
@@ -200,7 +204,7 @@ test("Bedrock: includes custom endpoint in options when specified", async () =>
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_PROFILE", "default")
set("AWS_PROFILE", "default")
},
fn: async () => {
const providers = await list()
@@ -233,10 +237,10 @@ test("Bedrock: autoloads when AWS_WEB_IDENTITY_TOKEN_FILE is present", async ()
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_WEB_IDENTITY_TOKEN_FILE", "/var/run/secrets/eks.amazonaws.com/serviceaccount/token")
Env.set("AWS_ROLE_ARN", "arn:aws:iam::123456789012:role/my-eks-role")
Env.set("AWS_PROFILE", "")
Env.set("AWS_ACCESS_KEY_ID", "")
set("AWS_WEB_IDENTITY_TOKEN_FILE", "/var/run/secrets/eks.amazonaws.com/serviceaccount/token")
set("AWS_ROLE_ARN", "arn:aws:iam::123456789012:role/my-eks-role")
set("AWS_PROFILE", "")
set("AWS_ACCESS_KEY_ID", "")
},
fn: async () => {
const providers = await list()
@@ -276,7 +280,7 @@ test("Bedrock: model with us. prefix should not be double-prefixed", async () =>
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_PROFILE", "default")
set("AWS_PROFILE", "default")
},
fn: async () => {
const providers = await list()
@@ -313,7 +317,7 @@ test("Bedrock: model with global. prefix should not be prefixed", async () => {
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_PROFILE", "default")
set("AWS_PROFILE", "default")
},
fn: async () => {
const providers = await list()
@@ -349,7 +353,7 @@ test("Bedrock: model with eu. prefix should not be double-prefixed", async () =>
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_PROFILE", "default")
set("AWS_PROFILE", "default")
},
fn: async () => {
const providers = await list()
@@ -385,7 +389,7 @@ test("Bedrock: model without prefix in US region should get us. prefix added", a
await Instance.provide({
directory: tmp.path,
init: async () => {
Env.set("AWS_PROFILE", "default")
set("AWS_PROFILE", "default")
},
fn: async () => {
const providers = await list()