29 lines
729 B
Go
29 lines
729 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestRunExample(t *testing.T) {
|
|
var output bytes.Buffer
|
|
if err := run(t.Context(), ".", &output); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var got struct {
|
|
Output string `json:"output"`
|
|
Valid *bool `json:"is_valid"`
|
|
Status string `json:"validation_status"`
|
|
Model string `json:"model"`
|
|
Tokens *int `json:"total_tokens"`
|
|
}
|
|
if err := json.Unmarshal(output.Bytes(), &got); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got.Output != "Ada finished the migration review." || got.Valid == nil || !*got.Valid ||
|
|
got.Status != "passed" || got.Model != "offline-model" || got.Tokens == nil || *got.Tokens != 18 {
|
|
t.Fatalf("unexpected execution summary: %+v", got)
|
|
}
|
|
}
|