diff --git a/gleam.toml b/gleam.toml index 1c79273..1d95096 100644 --- a/gleam.toml +++ b/gleam.toml @@ -20,3 +20,4 @@ gleam_regexp = ">= 1.1.1 and < 2.0.0" gleeunit = ">= 1.0.0 and < 2.0.0" gleam_httpc = ">= 5.0.0 and < 6.0.0" global_value = ">= 1.0.0 and < 2.0.0" +envoy = ">= 1.2.0 and < 2.0.0" diff --git a/manifest.toml b/manifest.toml index 5240412..dff225a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,6 +7,7 @@ # You should check this file into your source control repository. packages = [ + { name = "envoy", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "9C6FBB6BFA02A52798BEEC5977A738CAD6E4A057F4B67FD0C8061AD2502C191A" }, { name = "gleam_erlang", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "1124AD3AA21143E5AF0FC5CF3D9529F6DB8CA03E43A55711B60B6B7B3874375C" }, { name = "gleam_http", version = "4.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "82EA6A717C842456188C190AFB372665EA56CE13D8559BF3B1DD9E40F619EE0C" }, { name = "gleam_httpc", version = "5.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "C545172618D07811494E97AAA4A0FB34DA6F6D0061FDC8041C2F8E3BE2B2E48F" }, @@ -18,6 +19,7 @@ packages = [ ] [requirements] +envoy = { version = ">= 1.2.0 and < 2.0.0" } gleam_http = { version = ">= 4.3.0 and < 5.0.0" } gleam_httpc = { version = ">= 5.0.0 and < 6.0.0" } gleam_json = { version = ">= 3.1.0 and < 4.0.0" } diff --git a/test/possum_test.gleam b/test/possum_test.gleam index 6fa34f0..3c9b591 100644 --- a/test/possum_test.gleam +++ b/test/possum_test.gleam @@ -1,3 +1,4 @@ +import envoy import gleam/dict import gleam/dynamic import gleam/dynamic/decode @@ -6,6 +7,7 @@ import gleam/httpc import gleam/json import gleam/list import gleam/option +import gleam/result import gleeunit import global_value import possum @@ -23,8 +25,18 @@ pub type Context { Context(handle: String, did: did.Did, pds: String) } +fn context_from_env() -> Result(Context, Nil) { + use handle <- result.try(envoy.get("POSSUM_TEST_HANDLE")) + use pds <- result.try(envoy.get("POSSUM_TEST_PDS")) + use did_string <- result.try(envoy.get("POSSUM_TEST_DID")) + use did <- result.try(did.parse(did_string) |> result.replace_error(Nil)) + + Ok(Context(handle:, did:, pds:)) +} + fn global_data() -> Context { global_value.create_with_unique_name("possum_test.global.data", fn() { + use <- result.lazy_unwrap(context_from_env()) let handle = "bsky.app" let assert Ok(did_response) =