Browse Source
Add PutMetadata function to storage backends
Add PutMetadata function to storage backends
This function is not currently used, but it will be useful for helper scripts that need to regenerate metadata on the fly, especially scripts to migrate between storage backends. In the future, we can also use it to automatically regenerate metadata if it is found to be missing or corrupted. * Add PutMetadata function to storage backend interface and implementations * Rework metadata generation to be more efficient and work better with the PutMetadata function * Add a basic test for metadata generationpull/171/head
5 changed files with 130 additions and 29 deletions
-
36backends/localfs/localfs.go
-
31backends/s3/s3.go
-
1backends/storage.go
-
62helpers/helpers.go
-
29helpers/helpers_test.go
@ -0,0 +1,29 @@ |
|||
package helpers |
|||
|
|||
import ( |
|||
"strings" |
|||
"testing" |
|||
) |
|||
|
|||
func TestGenerateMetadata(t *testing.T) { |
|||
r := strings.NewReader("This is my test content") |
|||
m, err := GenerateMetadata(r) |
|||
if err != nil { |
|||
t.Fatal(err) |
|||
} |
|||
|
|||
expectedSha256sum := "966152d20a77e739716a625373ee15af16e8f4aec631a329a27da41c204b0171" |
|||
if m.Sha256sum != expectedSha256sum { |
|||
t.Fatalf("Sha256sum was %q instead of expected value of %q", m.Sha256sum, expectedSha256sum) |
|||
} |
|||
|
|||
expectedMimetype := "text/plain" |
|||
if m.Mimetype != expectedMimetype { |
|||
t.Fatalf("Mimetype was %q instead of expected value of %q", m.Mimetype, expectedMimetype) |
|||
} |
|||
|
|||
expectedSize := int64(23) |
|||
if m.Size != expectedSize { |
|||
t.Fatalf("Size was %d instead of expected value of %d", m.Size, expectedSize) |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue