Fixed code review comments, adjusted test error output and asserts
Nicholas J
8 years ago
0 | 0 | package zipkin_test |
1 | 1 | |
2 | 2 | import ( |
3 | "bytes" | |
3 | 4 | "testing" |
4 | 5 | |
5 | 6 | "github.com/go-kit/kit/tracing/zipkin" |
15 | 16 | encodedSpan := span.Encode() |
16 | 17 | annotations := encodedSpan.GetBinaryAnnotations() |
17 | 18 | |
18 | if annotations[0].Key != key { | |
19 | t.Errorf("Error: expected %s got %s", key, annotations[0].Key) | |
19 | if len(annotations) == 0 { | |
20 | t.Error("want non-zero length slice, have empty slice") | |
20 | 21 | } |
21 | 22 | |
22 | if string(annotations[0].Value) != string(value) { | |
23 | t.Errorf("Error: expected %s got %s", string(value), string(annotations[0].Value)) | |
23 | if want, have := key, annotations[0].Key; want != have { | |
24 | t.Errorf("want %q, got %q", want, have) | |
25 | } | |
26 | ||
27 | if want, have := value, annotations[0].Value; bytes.Compare(want, have) != 0 { | |
28 | t.Errorf("want %s, got %s", want, have) | |
24 | 29 | } |
25 | 30 | } |
26 | 31 | |
34 | 39 | encodedSpan := span.Encode() |
35 | 40 | annotations := encodedSpan.GetBinaryAnnotations() |
36 | 41 | |
37 | if annotations[0].Key != key { | |
38 | t.Errorf("Error: expected %s got %s", key, annotations[0].Key) | |
42 | if len(annotations) == 0 { | |
43 | t.Error("want non-zero length slice, have empty slice") | |
39 | 44 | } |
40 | 45 | |
41 | if string(annotations[0].Value) != value { | |
42 | t.Errorf("Error: expected %s got %s", value, string(annotations[0].Value)) | |
46 | if want, have := key, annotations[0].Key; want != have { | |
47 | t.Errorf("want %q, got %q", want, have) | |
48 | } | |
49 | ||
50 | if want, have := value, annotations[0].Value; bytes.Compare([]byte(want), have) != 0 { | |
51 | t.Errorf("want %s, got %s", want, have) | |
43 | 52 | } |
44 | 53 | } |