Skip to content

Commit

Permalink
update to whosonfirst/go-writer v0.6.0; update vendor deps; inline tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Sep 9, 2021
1 parent 82ce354 commit 6fd5115
Show file tree
Hide file tree
Showing 10 changed files with 819 additions and 8 deletions.
710 changes: 710 additions & 0 deletions fixtures/101736545.geojson

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/whosonfirst/go-writer-blob
go 1.16

require (
github.com/whosonfirst/go-writer v0.5.0
github.com/whosonfirst/go-writer v0.6.0
gocloud.dev v0.24.0
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ github.com/natefinch/atomic v0.0.0-20150920032501-a62ce929ffcc h1:7xGrl4tTpBQu5Z
github.com/natefinch/atomic v0.0.0-20150920032501-a62ce929ffcc/go.mod h1:1rLVY/DWf3U6vSZgH16S7pymfrhK2lcUlXjgGglw/lY=
github.com/natefinch/atomic v0.0.0-20200526193002-18c0533a5b09 h1:DXR0VtCesBD2ss3toN9OEeXszpQmW9dc3SvUbUfiBC0=
github.com/natefinch/atomic v0.0.0-20200526193002-18c0533a5b09/go.mod h1:1rLVY/DWf3U6vSZgH16S7pymfrhK2lcUlXjgGglw/lY=
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -409,6 +411,8 @@ github.com/whosonfirst/go-writer v0.4.1 h1:pAZ/cwaCM129PfwYy28ggCIRfL98OkrYxNnAx
github.com/whosonfirst/go-writer v0.4.1/go.mod h1:kFzhremCFtnkJdmviwJEPLFYKQ5+vq6ocJPxt1bHPFY=
github.com/whosonfirst/go-writer v0.5.0 h1:+pcSBpTR6KST+HaGrIiQXCC4u2G+S5Ry8BHVgQ56jhc=
github.com/whosonfirst/go-writer v0.5.0/go.mod h1:TDK4n9E2JPxiGlmSAdi8BQUSlpawEPMF5grpFDjfqRA=
github.com/whosonfirst/go-writer v0.6.0 h1:rlr8xGaUrSfUC4ogDHKj6F/bEkA1inbw95FEgCHbSAs=
github.com/whosonfirst/go-writer v0.6.0/go.mod h1:Qj0rZgdoFagSJ1xwhm60KyTgMU4DK5C6q5n8zKpgnj8=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
17 changes: 14 additions & 3 deletions vendor/github.com/natefinch/atomic/atomic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/natefinch/atomic/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/whosonfirst/go-writer/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/whosonfirst/go-writer/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ github.com/golang/protobuf/ptypes/timestamp
github.com/googleapis/gax-go/v2
github.com/googleapis/gax-go/v2/apierror
github.com/googleapis/gax-go/v2/apierror/internal/proto
# github.com/natefinch/atomic v0.0.0-20200526193002-18c0533a5b09
# github.com/natefinch/atomic v1.0.1
github.com/natefinch/atomic
# github.com/whosonfirst/go-writer v0.5.0
# github.com/whosonfirst/go-writer v0.6.0
## explicit
github.com/whosonfirst/go-writer
# go.opencensus.io v0.23.0
Expand Down
82 changes: 82 additions & 0 deletions writer_test.go
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)
}

}

0 comments on commit 6fd5115

Please sign in to comment.