mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-02-12 23:15:05 -05:00
### CHANGES - Introduce `cmd` directory for all main application binaries. - Move all Go packages into the `internal` directory. - Rename the `restapi` package to `server` for clarity. - Consolidate patterns and strategies into a new `data` directory. - Group all auxiliary scripts into a new `scripts` directory. - Move all documentation and images into a `docs` directory. - Update all Go import paths to reflect the new structure. - Adjust CI/CD workflows and build commands for new layout.
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package fsdb
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestStorage_SaveAndLoad(t *testing.T) {
|
|
dir := t.TempDir()
|
|
storage := &StorageEntity{Dir: dir}
|
|
name := "test"
|
|
content := []byte("test content")
|
|
if err := storage.Save(name, content); err != nil {
|
|
t.Fatalf("failed to save content: %v", err)
|
|
}
|
|
loadedContent, err := storage.Load(name)
|
|
if err != nil {
|
|
t.Fatalf("failed to load content: %v", err)
|
|
}
|
|
if string(loadedContent) != string(content) {
|
|
t.Errorf("expected %v, got %v", string(content), string(loadedContent))
|
|
}
|
|
}
|
|
|
|
func TestStorage_Exists(t *testing.T) {
|
|
dir := t.TempDir()
|
|
storage := &StorageEntity{Dir: dir}
|
|
name := "test"
|
|
if storage.Exists(name) {
|
|
t.Errorf("expected file to not exist")
|
|
}
|
|
if err := storage.Save(name, []byte("test content")); err != nil {
|
|
t.Fatalf("failed to save content: %v", err)
|
|
}
|
|
if !storage.Exists(name) {
|
|
t.Errorf("expected file to exist")
|
|
}
|
|
}
|
|
|
|
func TestStorage_Delete(t *testing.T) {
|
|
dir := t.TempDir()
|
|
storage := &StorageEntity{Dir: dir}
|
|
name := "test"
|
|
if err := storage.Save(name, []byte("test content")); err != nil {
|
|
t.Fatalf("failed to save content: %v", err)
|
|
}
|
|
if err := storage.Delete(name); err != nil {
|
|
t.Fatalf("failed to delete content: %v", err)
|
|
}
|
|
if storage.Exists(name) {
|
|
t.Errorf("expected file to be deleted")
|
|
}
|
|
}
|