fix test server setup: (#549)

* fix test server setup:
- go map access is not deterministic
- this can lead to a route: /foo/bar/1 matching /foo/bar before matching /foo/bar/1 if the map iteration go through /foo/bar first since the regex match wasn't bound to start and end anchors
- registering handlers now converts * in routes to .* for proper regex matching
- test server route handling now tries to fully match the handler route

* add missing /v1 prefix to fine-tuning job cancel test server handler
This commit is contained in:
Urjit Singh Bhatia
2023-11-09 00:20:39 -08:00
committed by GitHub
parent e3e065deb0
commit 8127072553
2 changed files with 9 additions and 3 deletions

View File

@@ -42,7 +42,7 @@ func TestFineTuningJob(t *testing.T) {
)
server.RegisterHandler(
"/fine_tuning/jobs/"+testFineTuninigJobID+"/cancel",
"/v1/fine_tuning/jobs/"+testFineTuninigJobID+"/cancel",
func(w http.ResponseWriter, _ *http.Request) {
resBytes, _ := json.Marshal(openai.FineTuningJob{})
fmt.Fprintln(w, string(resBytes))