-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblob_test.go
More file actions
58 lines (48 loc) · 1.33 KB
/
blob_test.go
File metadata and controls
58 lines (48 loc) · 1.33 KB
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
package main
import (
"fmt"
"testing"
)
func TestBinString(t *testing.T) {
tmp := newTmpFiles()
//TEST 1
_, err := tmp.createBinFileLink([]byte("hello people"))
if err != nil {
t.Errorf("TEST 1: FAILED. Something went wrong: %s\n", err)
}
//TEST 2
testThing := map[string]interface{}{
"Data": []interface{}{
map[string]interface{}{"string": "John", "int": 35, "bytes": []byte("I am bin data")},
map[string]interface{}{"string": "Jane", "int": 23, "bytes": []byte("I am bin data")},
map[string]interface{}{"string": "Mary", "int": 12, "bytes": []byte("I am bin data")},
},
}
testThing2 := []byte("I am bin data")
_, err1 := tmp.replaceBinStrWithLink(testThing)
_, err2 := tmp.replaceBinStrWithLink(testThing2)
if err1 != nil {
t.Errorf("TEST 2: FAILED. Something went wrong: %s\n", err1)
} else if err2 != nil {
t.Errorf("TEST 2: FAILED. Something went wrong: %s\n", err2)
}
targetMap := make(map[string]bool)
// Copy from the original map to the target map
for key, value := range tmp.generated {
targetMap[key] = value
}
//TEST 3
tmp.cleanupTmp()
success := true
for k := range targetMap {
if fileNotExist(fmt.Sprintf("/tmp/%s", k)) {
fmt.Printf("* %s has been removed\n", k)
} else {
success = false
t.Errorf("%s still exists\n", k)
}
}
if !success {
t.Errorf("Test 3: FAILED.\n")
}
}