-
Notifications
You must be signed in to change notification settings - Fork 7
/
saver_test.go
41 lines (38 loc) · 907 Bytes
/
saver_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package baraka
import (
"os"
"path/filepath"
"testing"
)
type SaveTest struct {
part Part
path string
expectedExistenceOfFile bool
expectedFilename string
expectedSizeOfFile int
}
func TestSaverSave(t *testing.T) {
tests := []SaveTest{
{
part: PartPlainText,
path: "test",
expectedExistenceOfFile: true,
expectedFilename: PartPlainText.Name,
expectedSizeOfFile: 15,
},
}
store := NewFilesystemStorage("./")
for _, test := range tests {
err := store.Save("test", test.part.Name, &test.part)
if err != nil {
t.Error(err)
}
file, err := os.Stat(filepath.Join(store.Path, test.path, test.expectedFilename))
if err != nil {
t.Error(err)
}
if file.Size() != int64(test.expectedSizeOfFile) {
t.Error("file size is not equal to expected file size")
}
}
}