Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve loading of test fixtures #306

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions api_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package brokerapi_test

import (
"fmt"
"io/ioutil"
"embed"
"io"
"path"
"testing"

Expand All @@ -31,14 +31,15 @@ func TestAPI(t *testing.T) {
RunSpecs(t, "API Suite")
}

//go:embed fixtures/*.json
var fixtures embed.FS

func fixture(name string) string {
filePath := path.Join("fixtures", name)
contents, err := ioutil.ReadFile(filePath)
if err != nil {
panic(fmt.Sprintf("Could not read fixture: %s", name))
}
GinkgoHelper()

return string(contents)
fh := must(fixtures.Open(path.Join("fixtures", name)))
defer fh.Close()
return string(must(io.ReadAll(fh)))
}

func uniqueID() string {
Expand Down
3 changes: 0 additions & 3 deletions fixtures/invalid_async_provision_error.json

This file was deleted.

Loading