This repository has been archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzstd_test.go
78 lines (67 loc) · 1.48 KB
/
zstd_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"bytes"
"testing"
)
func TestStoreAndLoad(t *testing.T) {
z := ZSTDStore{}
tc := "first time writing tests, heh"
err := z.Store("fixtures/test.txt", []byte(tc))
if err != nil {
t.Error(err)
}
d, err := z.Load("fixtures/test.txt")
if err != nil {
t.Error(err)
}
if !bytes.Equal(d, []byte(tc)) {
t.Errorf("expected: \"%s\", got: \"%s\"", tc, d)
}
}
func TestZSTDStore_Compress(t *testing.T) {
z := ZSTDStore{}
type args struct {
path string
}
tests := []struct {
name string
z ZSTDStore
args args
wantErr bool
}{
{"Compress fail", z, args{"fixtures/missingFile.txt"}, true},
{"Compress success", z, args{"fixtures/raw.txt"}, false},
}
// defer func(){
// z.
// }()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.z.Compress(tt.args.path); (err != nil) != tt.wantErr {
t.Errorf("ZSTDStore.Compress() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestZSTDStore_Decompress(t *testing.T) {
z := ZSTDStore{}
type args struct {
path string
}
tests := []struct {
name string
z ZSTDStore
args args
wantErr bool
}{
{"success", z, args{"fixtures/raw.txt.gz"}, false},
{"fail", z, args{"fixtures/missing.txt.gz"}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.z.Decompress(tt.args.path); (err != nil) != tt.wantErr {
t.Errorf("ZSTDStore.Decompress() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}