| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package telemetry |
| 6 |
|
| 7 |
import ( |
| 8 |
"testing" |
| 9 |
) |
| 10 |
|
| 11 |
|
| 12 |
func TestCounterPath(t *testing.T) { |
| 13 |
tests := []struct { |
| 14 |
path CounterPath |
| 15 |
want string |
| 16 |
}{ |
| 17 |
{ |
| 18 |
path: CounterPath{}, |
| 19 |
want: "", |
| 20 |
}, |
| 21 |
{ |
| 22 |
path: CounterPath{"counter"}, |
| 23 |
want: ":counter", |
| 24 |
}, |
| 25 |
{ |
| 26 |
path: CounterPath{"counter", "bucket"}, |
| 27 |
want: "counter:bucket", |
| 28 |
}, |
| 29 |
{ |
| 30 |
path: CounterPath{"path", "to", "counter"}, |
| 31 |
want: "path/to:counter", |
| 32 |
}, |
| 33 |
{ |
| 34 |
path: CounterPath{"multi", "component", "path", "bucket"}, |
| 35 |
want: "multi/component/path:bucket", |
| 36 |
}, |
| 37 |
{ |
| 38 |
path: CounterPath{"path", ""}, |
| 39 |
want: "path", |
| 40 |
}, |
| 41 |
} |
| 42 |
for _, tt := range tests { |
| 43 |
if got := tt.path.FullName(); got != tt.want { |
| 44 |
t.Errorf("CounterPath(%v).FullName() = %v, want %v", tt.path, got, tt.want) |
| 45 |
} |
| 46 |
} |
| 47 |
} |