Skip to content

Commit

Permalink
storage: additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jkowalski committed Dec 23, 2018
1 parent 8f3bf77 commit 97ad1ae
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
3 changes: 3 additions & 0 deletions storage/filesystem/filesystem_storage_test.go
Expand Up @@ -42,6 +42,9 @@ func TestFileStorage(t *testing.T) {

storagetesting.VerifyStorage(ctx, t, r)
storagetesting.AssertConnectionInfoRoundTrips(ctx, t, r)
if err := r.Close(ctx); err != nil {
t.Fatalf("err: %v", err)
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions storage/gcs/gcs_storage_test.go
Expand Up @@ -42,6 +42,9 @@ func TestGCSStorage(t *testing.T) {
}); err != nil {
t.Fatalf("unable to clear GCS bucket: %v", err)
}
if err := st.Close(ctx); err != nil {
t.Fatalf("err: %v", err)
}
}

func TestGCSStorageInvalid(t *testing.T) {
Expand Down
30 changes: 26 additions & 4 deletions storage/logging/logging_storage_test.go
Expand Up @@ -2,16 +2,38 @@ package logging

import (
"context"
"strings"
"testing"

"github.com/kopia/repo/internal/storagetesting"
)

func TestLoggingStorage(t *testing.T) {
var outputCount int
myPrefix := "myprefix"
myOutput := func(msg string, args ...interface{}) {
if !strings.HasPrefix(msg, myPrefix) {
t.Errorf("unexpected prefix %v", msg)
}
outputCount++
}

data := map[string][]byte{}
r := NewWrapper(storagetesting.NewMapStorage(data, nil, nil))
if r == nil {
t.Errorf("unexpected result: %v", r)
underlying := storagetesting.NewMapStorage(data, nil, nil)
st := NewWrapper(underlying, Output(myOutput), Prefix(myPrefix))
if st == nil {
t.Fatalf("unexpected result: %v", st)
}

ctx := context.Background()
storagetesting.VerifyStorage(ctx, t, st)
if err := st.Close(ctx); err != nil {
t.Fatalf("err: %v", err)
}
if outputCount == 0 {
t.Errorf("did not write any output!")
}
if got, want := st.ConnectionInfo().Type, underlying.ConnectionInfo().Type; got != want {
t.Errorf("unexpected connection infor %v, want %v", got, want)
}
storagetesting.VerifyStorage(context.Background(), t, r)
}
3 changes: 3 additions & 0 deletions storage/s3/s3_storage_test.go
Expand Up @@ -76,6 +76,9 @@ func TestS3Storage(t *testing.T) {

storagetesting.VerifyStorage(ctx, t, st)
storagetesting.AssertConnectionInfoRoundTrips(ctx, t, st)
if err := st.Close(ctx); err != nil {
t.Fatalf("err: %v", err)
}
}

func createBucket(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions storage/webdav/webdav_storage_test.go
Expand Up @@ -57,6 +57,9 @@ func TestWebDAVStorage(t *testing.T) {

storagetesting.VerifyStorage(ctx, t, r)
storagetesting.AssertConnectionInfoRoundTrips(ctx, t, r)
if err := r.Close(ctx); err != nil {
t.Fatalf("err: %v", err)
}
})
}
}

0 comments on commit 97ad1ae

Please sign in to comment.