1package jev23import (4 "context"5 "os"6 "testing"7 "time"89 "src.rest/cat/012/internal/sheet"10)1112// TestLive asks the real service one question of each kind. It only runs13// with JEV_LIVE_TEST=1 and TYPESAFE_API_KEY in the environment.14func TestLive(t *testing.T) {15 if os.Getenv("JEV_LIVE_TEST") != "1" {16 t.Skip("set JEV_LIVE_TEST=1 to call the live JEV service")17 }18 cfg := Config{APIKey: os.Getenv(KeyEnv), BaseURL: os.Getenv("TYPESAFE_BASE_URL"), Model: os.Getenv("TYPESAFE_DEFAULT_MODEL")}19 if cfg.APIKey == "" {20 t.Skip("no TYPESAFE_API_KEY")21 }22 client, err := NewClient(cfg)23 if err != nil {24 t.Fatal(err)25 }26 ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)27 defer cancel()28 text := "The package arrived crushed and support hasn't replied in a week."29 for _, c := range []sheet.RemoteCall{30 {Kind: "noul", State: text, Instructions: "Is this a complaint?", Criteria: [2]string{}},31 {Kind: "choice", State: text, Instructions: "Sentiment", Criteria: map[string]string{"positive": "positive", "negative": "negative", "neutral": "neutral"}},32 {Kind: "score", State: text, Instructions: "How urgent is this?", Criteria: []string{"low", "medium", "high"}},33 } {34 a := Ask(ctx, client, c)35 if a.Failed != "" {36 t.Fatalf("%s: %s", c.Kind, a.Failed)37 }38 t.Logf("%s: %s", c.Kind, Describe(c, a))39 }40}