MCPcopy Create free account
hub / github.com/coder/coder / TestModelFromConfig_Bedrock

Function TestModelFromConfig_Bedrock

coderd/x/chatd/chatprovider/chatprovider_test.go:853–995  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

851}
852
853func TestModelFromConfig_Bedrock(t *testing.T) {
854 t.Parallel()
855
856 const modelID = "us.anthropic.claude-sonnet-4-20250514-v1:0"
857
858 // This verifies the policy gate that permits an empty Bedrock key.
859 // End-to-end ambient credential auth would need a real AWS
860 // environment or a more complete mock, which is outside this scope.
861 t.Run("AllowsEmptyAPIKeyForAmbientCredentials", func(t *testing.T) {
862 t.Parallel()
863
864 model, err := chatprovider.ModelFromConfig(
865 fantasybedrock.Name,
866 modelID,
867 chatprovider.ProviderAPIKeys{
868 ByProvider: map[string]string{
869 fantasybedrock.Name: "",
870 },
871 },
872 chatprovider.UserAgent(),
873 nil,
874 nil,
875 )
876 require.NoError(t, err)
877 require.NotNil(t, model)
878 require.Equal(t, fantasybedrock.Name, model.Provider())
879 })
880
881 t.Run("RequiresResolvedProviderForAmbientCredentials", func(t *testing.T) {
882 t.Parallel()
883
884 model, err := chatprovider.ModelFromConfig(
885 fantasybedrock.Name,
886 modelID,
887 chatprovider.ProviderAPIKeys{},
888 chatprovider.UserAgent(),
889 nil,
890 nil,
891 )
892 require.Nil(t, model)
893 require.EqualError(t, err, "API key for provider \"bedrock\" is not set")
894 })
895
896 t.Run("ForwardsBaseURLAndExplicitAPIKey", func(t *testing.T) {
897 t.Parallel()
898 ctx := testutil.Context(t, testutil.WaitShort)
899
900 type requestCapture struct {
901 Path string
902 Authorization string
903 UserAgent string
904 }
905
906 requests := make(chan requestCapture, 1)
907 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
908 requests <- requestCapture{
909 Path: r.URL.Path,
910 Authorization: r.Header.Get("Authorization"),

Callers

nothing calls this directly

Calls 14

CloseMethod · 0.95
ModelFromConfigFunction · 0.92
UserAgentFunction · 0.92
ContextFunction · 0.92
TryReceiveFunction · 0.92
EncodeMethod · 0.80
RunMethod · 0.65
GetMethod · 0.65
SetMethod · 0.65
EqualMethod · 0.45
ProviderMethod · 0.45

Tested by

no test coverage detected