mirror of https://github.com/perkeep/perkeep.git
Merge branch 'master' of https://camlistore.googlesource.com/camlistore
This commit is contained in:
commit
a666df55c6
2
TESTS
2
TESTS
|
@ -1,5 +1,7 @@
|
|||
Tests needed
|
||||
|
||||
-- finish storagetest.Test
|
||||
|
||||
-- pkg/client --- test FetchVia against a server returning compressed content.
|
||||
(fix in 3fa6d69405f036308931dd36e5070b2b19dbeadf without a new test)
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@
|
|||
},
|
||||
|
||||
"/r1/": {
|
||||
"handler": "storage-filesystem",
|
||||
"handler": "storage-diskpacked",
|
||||
"handlerArgs": {
|
||||
"path": ["_env", "${CAMLI_ROOT_REPLICA1}"]
|
||||
}
|
||||
|
|
|
@ -88,12 +88,8 @@ func newStorage(root string, maxFileSize int64) (s *storage, err error) {
|
|||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
closeErr := index.Close()
|
||||
// just returning the first error - if the index or disk is corrupt
|
||||
// and can't close, it's very likely these two errors are related and
|
||||
// have the same root cause.
|
||||
if err == nil {
|
||||
err = closeErr
|
||||
if err != nil {
|
||||
index.Close()
|
||||
}
|
||||
}()
|
||||
if maxFileSize <= 0 {
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
Copyright 2013 The Camlistore Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package diskpacked
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"camlistore.org/pkg/blobserver"
|
||||
"camlistore.org/pkg/blobserver/storagetest"
|
||||
)
|
||||
|
||||
func newTempDiskpacked(t *testing.T) (sto blobserver.Storage, cleanup func()) {
|
||||
dir, err := ioutil.TempDir("", "diskpacked-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s, err := newStorage(dir, 1<<20)
|
||||
if err != nil {
|
||||
t.Fatalf("newStorage: %v", err)
|
||||
}
|
||||
return s, func() {
|
||||
s.Close()
|
||||
os.RemoveAll(dir)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiskpacked(t *testing.T) {
|
||||
storagetest.Test(t, newTempDiskpacked)
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
Copyright 2013 The Camlistore Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package storagetest tests blobserver.Storage implementations
|
||||
package storagetest
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"camlistore.org/pkg/blobserver"
|
||||
"camlistore.org/pkg/test"
|
||||
)
|
||||
|
||||
func Test(t *testing.T, fn func(*testing.T) (sto blobserver.Storage, cleanup func())) {
|
||||
sto, cleanup := fn(t)
|
||||
defer cleanup()
|
||||
|
||||
t.Logf("Testing receive")
|
||||
|
||||
b1 := &test.Blob{"foo"}
|
||||
b1s, err := sto.ReceiveBlob(b1.BlobRef(), b1.Reader())
|
||||
if err != nil {
|
||||
t.Fatalf("ReceiveBlob of b1: %v", err)
|
||||
}
|
||||
if b1s != b1.SizedRef() {
|
||||
t.Fatal("Received %v; want %v", b1s, b1.SizedRef())
|
||||
}
|
||||
|
||||
// TODO: test all the other methods
|
||||
}
|
|
@ -37,6 +37,10 @@ func (tb *Blob) BlobRef() blob.Ref {
|
|||
return blob.RefFromHash(h)
|
||||
}
|
||||
|
||||
func (tb *Blob) SizedRef() blob.SizedRef {
|
||||
return blob.SizedRef{tb.BlobRef(), int64(len(tb.Contents))}
|
||||
}
|
||||
|
||||
func (tb *Blob) BlobRefSlice() []blob.Ref {
|
||||
return []blob.Ref{tb.BlobRef()}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue