-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update to whosonfirst/go-writer v0.6.0; update vendor deps; inline tests
- Loading branch information
thisisaaronland
committed
Sep 9, 2021
1 parent
82ce354
commit 6fd5115
Showing
10 changed files
with
819 additions
and
8 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
.../github.com/whosonfirst/go-writer/file.go → ...or/github.com/whosonfirst/go-writer/fs.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package writer | ||
|
||
import ( | ||
_ "gocloud.dev/blob/fileblob" | ||
) | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/whosonfirst/go-writer" | ||
// _ "github.com/whosonfirst/go-writer-blob" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestFileWriter(t *testing.T) { | ||
|
||
ctx := context.Background() | ||
|
||
cwd, err := os.Getwd() | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
tmpdir := os.TempDir() | ||
data_root := filepath.Join(tmpdir, "data") | ||
|
||
_, err = os.Stat(data_root) | ||
|
||
if err != nil { | ||
|
||
err := os.MkdirAll(data_root, 0755) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
target_root := fmt.Sprintf("file://%s", data_root) | ||
|
||
source_root := filepath.Join(cwd, "fixtures") | ||
feature_path := filepath.Join(source_root, "101736545.geojson") | ||
|
||
target_path := "101/736/545/101736545.geojson" | ||
|
||
wr, err := writer.NewWriter(ctx, target_root) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
feature_fh, err := os.Open(feature_path) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
defer feature_fh.Close() | ||
|
||
_, err = wr.Write(ctx, target_path, feature_fh) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
test_path := filepath.Join(data_root, target_path) | ||
|
||
_, err = os.Stat(test_path) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
err = os.RemoveAll(data_root) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
} |