-
Notifications
You must be signed in to change notification settings - Fork 0
/
freeze_test.go
43 lines (39 loc) · 959 Bytes
/
freeze_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
package span
import (
"github.com/segmentio/encoding/json"
"io/ioutil"
"os"
"reflect"
"testing"
)
func filenames(fis []os.FileInfo) (result []string) {
for _, fi := range fis {
result = append(result, fi.Name())
}
return
}
func TestUnfreezeFilterConfig(t *testing.T) {
dir, blob, err := UnfreezeFilterConfig("fixtures/frozen.zip")
if err != nil {
t.Errorf("expected err nil, got %v", err)
}
f, err := os.Open(blob)
if err != nil {
t.Errorf("could not open blob file %v", err)
}
defer f.Close()
defer os.RemoveAll(dir)
dec := json.NewDecoder(f)
var payload = make(map[string]interface{})
if err := dec.Decode(&payload); err != nil {
t.Errorf("could not decode JSON: %v", err)
}
fis, err := ioutil.ReadDir(dir)
if err != nil {
t.Errorf("could not read dir: %v", err)
}
want := []string{"blob", "files", "mapping.json"}
if !reflect.DeepEqual(filenames(fis), want) {
t.Errorf("want %v, got %v", want, filenames(fis))
}
}