Skip to content

Commit

Permalink
Embed testdata/flatgeobuf/*.fgb in example tests
Browse files Browse the repository at this point in the history
The purpose of this change is to see if it will enable the example
tests to run on https://pkg.go.dev/github.com/gogama/flatgeobuf.

Before this change, at least, they are failing with errors like the one
shown below. If this change isn't successful, I will most likely revert
it and perhaps resort to some other form of embedding, like directly
putting the FGB bytes in a []byte within `example_test.go`.

```
panic: open testdata/flatgeobuf/empty.fgb: no such file or directory

goroutine 1 [running]:
main.openFile({0x4a7312?, 0x40b33e?})
	/tmp/sandbox2858312298/prog.go:13 +0x3c
main.main()
	/tmp/sandbox2858312298/prog.go:24 +0x3d
```
  • Loading branch information
vcschapp committed Dec 14, 2023
1 parent c064345 commit 4cab23f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ NEXT STEPS:
4. Cut v0.9.5-beta.
5. Add GitHub action to build/test on commit? (If free.)
6. Update copyrights to 2024.
7. Cut v1.0.0.
7. Clear out any remaining TODO, for e.g. example_test.go.
8. Cut v1.0.0.

Future directions:
1. Another interesting interaction system would be an Appender which
Expand Down
10 changes: 7 additions & 3 deletions flatgeobuf/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ package flatgeobuf_test

import (
"bytes"
"embed"
"encoding/hex"
"fmt"
"os"
"io/fs"
"sort"

"github.com/gogama/flatgeobuf/flatgeobuf"
Expand All @@ -17,8 +18,11 @@ import (
flatbuffers "github.com/google/flatbuffers/go"
)

func openFile(name string) *os.File {
f, err := os.Open(name)
//go:embed testdata/flatgeobuf/*.fgb
var testFiles embed.FS

func openFile(name string) fs.File {
f, err := testFiles.Open(name)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 4cab23f

Please sign in to comment.