41 lines
1.8 KiB
Go
41 lines
1.8 KiB
Go
package ckprompt
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"strings"
|
|
"testing"
|
|
|
|
"go.maximumdirect.net/ckconfig"
|
|
commandkit "go.maximumdirect.net/commandkit"
|
|
"go.maximumdirect.net/configkit"
|
|
promptkit "go.maximumdirect.net/promptkit"
|
|
)
|
|
|
|
type smokeTransport func(*http.Request) (*http.Response, error)
|
|
|
|
func (f smokeTransport) RoundTrip(r *http.Request) (*http.Response, error) { return f(r) }
|
|
|
|
func TestVLLMAuthenticationEvidenceFlowsThroughCommand(t *testing.T) {
|
|
source := configkit.Input{Destination: configkit.Keys("promptkit"), Source: configkit.Mapping("fixture", map[string]any{"backends": []any{map[string]any{"id": "local", "provider": "vllm", "endpoint": "https://example.invalid/v1", "zero_cost": false}}})}
|
|
client := &http.Client{Transport: smokeTransport(func(r *http.Request) (*http.Response, error) {
|
|
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(`{"object":"list","data":[]}`)), Request: r}, nil
|
|
})}
|
|
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{Main: &source}, HTTPClient: client}, promptkit.WithBundledOpenRouter(false))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
loader := func(context.Context, ckconfig.Selection, struct{}, struct{}) (*promptkit.Engine, error) {
|
|
return engine, nil
|
|
}
|
|
suite := WithSmokeTesting(FromEngine(loader), loader, nil)
|
|
app := newPromptTestApp(t, Command(suite))
|
|
var out bytes.Buffer
|
|
result := app.Execute(context.Background(), []string{"promptkit", "test", "authentication", "--llm-backend=local", "--format=json"}, commandkit.Streams{Out: &out})
|
|
if result.Status != 0 || !strings.Contains(out.String(), `"supported": true`) || !strings.Contains(out.String(), `"applicable": true`) || !strings.Contains(out.String(), `"credentials_accepted": true`) {
|
|
t.Fatalf("outcome=%#v report=%s", result, out.String())
|
|
}
|
|
}
|