返回 DeepSeek-Reasonix
main_test.go
根目录 / sdk / go / examples / starterextension / main_test.go
1 package main
2
3 import (
4 "context"
5 "encoding/json"
6 "testing"
7 )
8
9 func TestInterceptInputRewritesStarterPrefix(t *testing.T) {
10 result, err := interceptInput(context.Background(), "input.receive", json.RawMessage(`{"text":"starter: explain sidecars"}`))
11 if err != nil {
12 t.Fatal(err)
13 }
14 if result == nil || result.Decision != "replace" {
15 t.Fatalf("result = %#v, want replace", result)
16 }
17 want := `{"text":"explain sidecars [rewritten by starter-extension]"}`
18 if string(result.Replacement) != want {
19 t.Fatalf("replacement = %s, want %s", result.Replacement, want)
20 }
21 }
22
23 func TestInterceptInputContinuesOrdinaryText(t *testing.T) {
24 result, err := interceptInput(context.Background(), "input.receive", json.RawMessage(`{"text":"ordinary input"}`))
25 if err != nil {
26 t.Fatal(err)
27 }
28 if result == nil || result.Decision != "continue" {
29 t.Fatalf("result = %#v, want continue", result)
30 }
31 }
32
32 lines GO