/
fconcat_test.go
58 lines (45 loc) · 1.05 KB
/
fconcat_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
package fconcat_test
import (
"fmt"
"os"
"testing"
"github.com/ciaranarcher/fconcat"
)
var bucket = os.Getenv("BUCKET")
var urlsTwo = []string{
fmt.Sprintf("%s/one.mp3", bucket),
fmt.Sprintf("%s/two.mp3", bucket),
}
var urlsThree = []string{
fmt.Sprintf("%s/one.mp3", bucket),
fmt.Sprintf("%s/two.mp3", bucket),
fmt.Sprintf("%s/three.mp3", bucket),
}
func TestConcat(t *testing.T) {
fName, err := fconcat.Concat(urlsThree)
if err != nil {
t.Error("unable to concatenate files: ", err)
}
f, err := os.Open(fName)
if err != nil {
t.Error("unable to open concatenated file.")
}
fi, err := f.Stat()
if err != nil {
t.Error("unable to get info about concatenated file.")
}
expectedSize := int64(870192)
if fi.Size() != expectedSize {
t.Error(fmt.Sprintf("byte size incorrect: expected %d and got %d", expectedSize, fi.Size()))
}
}
func BenchmarkConcat2(b *testing.B) {
for n := 0; n < b.N; n++ {
_, _ = fconcat.Concat(urlsTwo)
}
}
func BenchmarkConcat3(b *testing.B) {
for n := 0; n < b.N; n++ {
_, _ = fconcat.Concat(urlsThree)
}
}