forked from stapelberg/rsyncprom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsyncprom_test.go
44 lines (38 loc) · 889 Bytes
/
rsyncprom_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
package rsyncprom
import (
"fmt"
"log"
"strings"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestParse(t *testing.T) {
got, err := Parse(strings.NewReader(`
sent 1,192,097 bytes received 1,039 bytes 795,424.00 bytes/sec
total size is 1,188,046 speedup is 1.00
`))
if err != nil {
t.Fatal(err)
}
want := &Stats{
Found: true,
TotalWritten: 1192097,
TotalRead: 1039,
BytesPerSec: 795424,
TotalSize: 1188046,
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("parse(): unexpected output: diff (-want +got):\n%s", diff)
}
}
func ExampleParse() {
stats, err := Parse(strings.NewReader(`
sent 1,192,097 bytes received 1,039 bytes 795,424.00 bytes/sec
total size is 1,188,046 speedup is 1.00
`))
if err != nil {
log.Fatal(err)
}
fmt.Printf("corpus is %d bytes big!\n", stats.TotalSize)
// Output: corpus is 1188046 bytes big!
}