upgrade tests for api no longer returning verbose
parent
3b1ccfae48
commit
f37098223e
|
|
@ -367,10 +367,15 @@ func handleAPIChatBotPut(w http.ResponseWriter, r *http.Request) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
result := bytes.TrimSuffix(buff.Bytes(), []byte(reversePrompt))
|
result := bytes.TrimSuffix(buff.Bytes(), []byte(reversePrompt))
|
||||||
|
priorContent, err := os.ReadFile(inputF)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
shortResult := result[len(priorContent):]
|
||||||
if err := os.WriteFile(promptF, result, os.ModePerm); err != nil {
|
if err := os.WriteFile(promptF, result, os.ModePerm); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w.Write(result)
|
w.Write(shortResult)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ func TestAPIV0ChatBot(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Logf("(%d) %s", resp.StatusCode, got)
|
t.Logf("(%d) %s", resp.StatusCode, got)
|
||||||
|
if len(got) < 100 {
|
||||||
|
t.Error(string(got))
|
||||||
|
}
|
||||||
|
|
||||||
resp2 := httpDo(t, http.MethodPut, "/api/v0/chatbot", body.Encode())
|
resp2 := httpDo(t, http.MethodPut, "/api/v0/chatbot", body.Encode())
|
||||||
got2, err := io.ReadAll(resp2.Body)
|
got2, err := io.ReadAll(resp2.Body)
|
||||||
|
|
@ -37,11 +40,12 @@ func TestAPIV0ChatBot(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Logf("(%d) %s", resp2.StatusCode, got2)
|
t.Logf("(%d) %s", resp2.StatusCode, got2)
|
||||||
|
if len(got2) < 100 {
|
||||||
|
t.Error(string(got2))
|
||||||
|
}
|
||||||
|
|
||||||
if len(got) == len(got2) {
|
if bytes.Equal(got, got2) {
|
||||||
t.Error("nothing new as of put")
|
t.Error("dupe generation")
|
||||||
} else if !bytes.HasPrefix(got2, got) {
|
|
||||||
t.Error("put was not a continuation")
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -52,6 +56,9 @@ func TestAPIV0ChatBot(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Logf("(%d) %s", resp.StatusCode, got)
|
t.Logf("(%d) %s", resp.StatusCode, got)
|
||||||
|
if len(got) < 100 {
|
||||||
|
t.Error(string(got))
|
||||||
|
}
|
||||||
|
|
||||||
resp2 := httpDo(t, http.MethodPost, "/api/v0/chatbot", body.Encode())
|
resp2 := httpDo(t, http.MethodPost, "/api/v0/chatbot", body.Encode())
|
||||||
got2, err := io.ReadAll(resp2.Body)
|
got2, err := io.ReadAll(resp2.Body)
|
||||||
|
|
@ -59,9 +66,12 @@ func TestAPIV0ChatBot(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Logf("(%d) %s", resp2.StatusCode, got2)
|
t.Logf("(%d) %s", resp2.StatusCode, got2)
|
||||||
|
if len(got2) < 100 {
|
||||||
|
t.Error(string(got))
|
||||||
|
}
|
||||||
|
|
||||||
if bytes.HasPrefix(got2, got) {
|
if bytes.Equal(got, got2) {
|
||||||
t.Error("post over post was a continuation")
|
t.Error("dupe generation")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -72,6 +82,9 @@ func TestAPIV0ChatBot(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Logf("(%d) %s", resp.StatusCode, got)
|
t.Logf("(%d) %s", resp.StatusCode, got)
|
||||||
|
if len(got) > 100 {
|
||||||
|
t.Error(string(got))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -83,6 +96,7 @@ func goTestMain(t *testing.T) func() {
|
||||||
ctx, cleanup := contextWithCleanup(ctx)
|
ctx, cleanup := contextWithCleanup(ctx)
|
||||||
config(ctx)
|
config(ctx)
|
||||||
Config.Port += 10
|
Config.Port += 10
|
||||||
|
Config.ChatBot.N = 32
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue