Load native PromptKit settings through application configuration version six
This commit is contained in:
@@ -83,95 +83,6 @@ func TestValidateConcurrencyRules(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatePromptKitSourcesAreMutuallyExclusive(t *testing.T) {
|
||||
cfg := Default()
|
||||
cfg.PromptKit = PromptKitConfig{ProfileDir: "./profiles", ProfileFile: "./profile.yml"}
|
||||
assertValidationContains(t, cfg, "promptkit profile_dir and profile_file are mutually exclusive")
|
||||
}
|
||||
|
||||
func TestValidatePromptKitTransientRetries(t *testing.T) {
|
||||
if got := Default().PromptKit.TransientRetries; got != defaultTransientRetries {
|
||||
t.Fatalf("default transient retries = %d, want %d", got, defaultTransientRetries)
|
||||
}
|
||||
for _, retries := range []int{0, 4} {
|
||||
cfg := Default()
|
||||
cfg.PromptKit.TransientRetries = retries
|
||||
if err := cfg.Validate(); err != nil {
|
||||
t.Fatalf("Validate() with transient retries %d error = %v", retries, err)
|
||||
}
|
||||
}
|
||||
negative := Default()
|
||||
negative.PromptKit.TransientRetries = -1
|
||||
assertValidationContains(t, negative, "promptkit.transient_retries must not be negative")
|
||||
}
|
||||
|
||||
func TestValidatePromptKitLocalBackendEndpoints(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
endpoint string
|
||||
profileSource PromptKitConfig
|
||||
}{
|
||||
{
|
||||
name: "HTTP endpoint with path and profile directory",
|
||||
endpoint: "http://localhost:8000/v1",
|
||||
profileSource: PromptKitConfig{ProfileDir: "./profiles"},
|
||||
},
|
||||
{
|
||||
name: "case-insensitive HTTPS endpoint and profile file",
|
||||
endpoint: "HTTPS://inference.example.test/api",
|
||||
profileSource: PromptKitConfig{ProfileFile: "./profiles.yml"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cfg := Default()
|
||||
cfg.PromptKit = tt.profileSource
|
||||
cfg.PromptKit.LocalBackend = &PromptKitLocalBackendConfig{
|
||||
Endpoint: tt.endpoint,
|
||||
ConcurrencyLimit: 2,
|
||||
}
|
||||
if err := cfg.Validate(); err != nil {
|
||||
t.Fatalf("Validate() error = %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatePromptKitLocalBackendRejectsInvalidValues(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
endpoint string
|
||||
concurrencyLimit int
|
||||
want string
|
||||
}{
|
||||
{name: "blank endpoint", endpoint: " ", want: "promptkit.local_backend.endpoint"},
|
||||
{name: "relative URL", endpoint: "localhost:8000/v1", want: "promptkit.local_backend.endpoint"},
|
||||
{name: "unsupported scheme", endpoint: "ftp://localhost/model", want: "promptkit.local_backend.endpoint"},
|
||||
{name: "missing host", endpoint: "http:///v1", want: "promptkit.local_backend.endpoint"},
|
||||
{name: "user information", endpoint: "http://user:secret@localhost/v1", want: "promptkit.local_backend.endpoint"},
|
||||
{name: "query", endpoint: "http://localhost/v1?model=example", want: "promptkit.local_backend.endpoint"},
|
||||
{name: "empty query", endpoint: "http://localhost/v1?", want: "promptkit.local_backend.endpoint"},
|
||||
{name: "fragment", endpoint: "http://localhost/v1#model", want: "promptkit.local_backend.endpoint"},
|
||||
{name: "empty fragment", endpoint: "http://localhost/v1#", want: "promptkit.local_backend.endpoint"},
|
||||
{
|
||||
name: "negative concurrency",
|
||||
endpoint: "http://localhost:8000/v1",
|
||||
concurrencyLimit: -1,
|
||||
want: "promptkit.local_backend.concurrency_limit",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cfg := Default()
|
||||
cfg.PromptKit.LocalBackend = &PromptKitLocalBackendConfig{
|
||||
Endpoint: tt.endpoint,
|
||||
ConcurrencyLimit: tt.concurrencyLimit,
|
||||
}
|
||||
assertValidationContains(t, cfg, tt.want)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateStateSurfaceRules(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user