Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry committed Feb 9, 2024
1 parent a324b1b commit ff4d5d1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pmtiles/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ func TestHttpBucketRequestRequestEtagFailed(t *testing.T) {
}

func TestFileBucketReplace(t *testing.T) {
dir := t.TempDir()
dir := t.TempDir() + string(os.PathSeparator)
bucketURL, _, err := NormalizeBucketKey("", dir, "")
assert.Nil(t, err)
fmt.Println(bucketURL)
bucket, err := OpenBucket(context.Background(), bucketURL, "")
assert.Nil(t, err)
assert.NotNil(t, bucket)
assert.Nil(t, os.WriteFile(dir+"/archive.pmtiles", []byte{1, 2, 3}, 0666))
assert.Nil(t, os.WriteFile(dir+"archive.pmtiles", []byte{1, 2, 3}, 0666))

// first read from file
reader, etag1, err := bucket.NewRangeReaderEtag(context.Background(), "archive.pmtiles", 1, 1, "")
Expand All @@ -135,7 +135,7 @@ func TestFileBucketReplace(t *testing.T) {
assert.Equal(t, []byte{2}, data)

// change file, verify etag changes
assert.Nil(t, os.WriteFile(dir+"/archive.pmtiles", []byte{4, 5, 6, 7}, 0666))
assert.Nil(t, os.WriteFile(dir+"archive.pmtiles", []byte{4, 5, 6, 7}, 0666))
reader, etag2, err := bucket.NewRangeReaderEtag(context.Background(), "archive.pmtiles", 1, 1, "")
assert.Nil(t, err)
data, err = io.ReadAll(reader)
Expand All @@ -149,17 +149,17 @@ func TestFileBucketReplace(t *testing.T) {
}

func TestFileBucketRename(t *testing.T) {
dir := t.TempDir()
assert.Nil(t, os.WriteFile(dir+"/archive.pmtiles", []byte{1, 2, 3}, 0666))
assert.Nil(t, os.WriteFile(dir+"/archive2.pmtiles", []byte{4, 5, 6, 7}, 0666))
dir := t.TempDir() + string(os.PathSeparator)
assert.Nil(t, os.WriteFile(dir+"archive.pmtiles", []byte{1, 2, 3}, 0666))
assert.Nil(t, os.WriteFile(dir+"archive2.pmtiles", []byte{4, 5, 6, 7}, 0666))

bucketURL, _, err := NormalizeBucketKey("", dir, "")
assert.Nil(t, err)
fmt.Println(bucketURL)
bucket, err := OpenBucket(context.Background(), bucketURL, "")
assert.Nil(t, err)
assert.NotNil(t, bucket)
assert.Nil(t, os.WriteFile(dir+"/archive.pmtiles", []byte{1, 2, 3}, 0666))
assert.Nil(t, os.WriteFile(dir+"archive.pmtiles", []byte{1, 2, 3}, 0666))

// first read from file
reader, etag1, err := bucket.NewRangeReaderEtag(context.Background(), "archive.pmtiles", 1, 1, "")
Expand All @@ -169,8 +169,8 @@ func TestFileBucketRename(t *testing.T) {
assert.Equal(t, []byte{2}, data)

// change file, verify etag changes
os.Rename(dir+"/archive.pmtiles", dir+"/archive3.pmtiles")
os.Rename(dir+"/archive2.pmtiles", dir+"/archive.pmtiles")
os.Rename(dir+"archive.pmtiles", dir+"archive3.pmtiles")
os.Rename(dir+"archive2.pmtiles", dir+"archive.pmtiles")
reader, etag2, err := bucket.NewRangeReaderEtag(context.Background(), "archive.pmtiles", 1, 1, "")
assert.Nil(t, err)
data, err = io.ReadAll(reader)
Expand Down

0 comments on commit ff4d5d1

Please sign in to comment.