Skip to content

Use non-empty structs in test server handlers #487

Open
@sashabaranov

Description

@sashabaranov

Currently, in many test cases, we return empty structs from the test server. For example:

server.RegisterHandler("/v1/engines/text-davinci-003", func(w http.ResponseWriter, r *http.Request) {
	resBytes, _ := json.Marshal(Engine{}) // <------------- Here we return empty Engine struct
	fmt.Fprintln(w, string(resBytes))
})

It is possible for such tests not to cover a case where client does not return a proper response, see for example this discussion: #485 (comment)

It would be good to make these structs non-empty, and the best solution would probably be to randomize them (keeping randomization logic in the internal/test directory). So in the end we'll get something like:

server.RegisterHandler("/v1/engines/text-davinci-003", func(w http.ResponseWriter, r *http.Request) {
	resBytes, _ := json.Marshal(Engine{ID: test.randomString(), Object: test.randomString()})
	fmt.Fprintln(w, string(resBytes))
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions