go-openai icon indicating copy to clipboard operation
go-openai copied to clipboard

Resolve #487: Enhance tests and fix linting issues

Open ealvar3z opened this issue 2 years ago • 2 comments

Describe the change

  • Add randomized fields to Engine structs in tests

Describe your solution

  • Implement cryptographically secure random utility functions

Tests

  • Make these structs non-empty, by randomizing them, while keeping randomization logic in the internal/test directory (internal/test/random.go). 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))
})
  • Address golangci-lint warnings

Additional context

  • None

Issue: #487

ealvar3z avatar Sep 12 '23 23:09 ealvar3z

Codecov Report

Merging #491 (5341647) into master (3589837) will increase coverage by 0.28%. Report is 7 commits behind head on master. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #491      +/-   ##
==========================================
+ Coverage   97.30%   97.58%   +0.28%     
==========================================
  Files          18       19       +1     
  Lines         780      871      +91     
==========================================
+ Hits          759      850      +91     
  Misses         15       15              
  Partials        6        6              
Files Coverage Δ
embeddings.go 100.00% <100.00%> (ø)

... and 14 files with indirect coverage changes

codecov[bot] avatar Sep 12 '23 23:09 codecov[bot]

Thank you for the PR!

sashabaranov avatar Sep 13 '23 08:09 sashabaranov