feat: bootstrap foundation application
This commit is contained in:
34
apps/server/internal/store/content_store_test.go
Normal file
34
apps/server/internal/store/content_store_test.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestContentStoreDeduplicatesByHash(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
|
||||
store, err := New(root)
|
||||
if err != nil {
|
||||
t.Fatalf("New() error = %v", err)
|
||||
}
|
||||
|
||||
first, err := store.PutBytes([]byte("hello"))
|
||||
if err != nil {
|
||||
t.Fatalf("PutBytes() first error = %v", err)
|
||||
}
|
||||
|
||||
second, err := store.PutBytes([]byte("hello"))
|
||||
if err != nil {
|
||||
t.Fatalf("PutBytes() second error = %v", err)
|
||||
}
|
||||
|
||||
if first.Hash != second.Hash {
|
||||
t.Fatalf("hash mismatch: %s != %s", first.Hash, second.Hash)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(filepath.Join(root, first.Hash[0:2], first.Hash[2:4], first.Hash)); err != nil {
|
||||
t.Fatalf("expected content file to exist: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user