Debian Codegraph @

stress/v2/stress_client/commune_test.go

raw symbols SCIP
1 package stressClient
2
3 import (
4 "testing"
5 )
6
7 func TestCommunePoint(t *testing.T) {
8 comm := newCommune(5)
9 pt := "write,tag=tagVal fooField=5 1460912595"
10 comm.ch <- pt
11 point := comm.point("s")
12 if string(point.Name()) != "write" {
13 t.Errorf("expected: write\ngot: %v", string(point.Name()))
14 }
15 if point.Tags().GetString("tag") != "tagVal" {
16 t.Errorf("expected: tagVal\ngot: %v", point.Tags().GetString("tag"))
17 }
18 fields, err := point.Fields()
19 if err != nil {
20 t.Fatal(err)
21 }
22 if int(fields["fooField"].(float64)) != 5 {
23 t.Errorf("expected: 5\ngot: %v\n", fields["fooField"])
24 }
25 // Make sure commune returns the prev point
26 comm.ch <- ""
27 point = comm.point("s")
28 if string(point.Name()) != "write" {
29 t.Errorf("expected: write\ngot: %v", string(point.Name()))
30 }
31 if point.Tags().GetString("tag") != "tagVal" {
32 t.Errorf("expected: tagVal\ngot: %v", point.Tags().GetString("tag"))
33 }
34 if int(fields["fooField"].(float64)) != 5 {
35 t.Errorf("expected: 5\ngot: %v\n", fields["fooField"])
36 }
37 }
38
39 func TestSetCommune(t *testing.T) {
40 sf, _, _ := NewTestStressTest()
41 ch := sf.SetCommune("foo_name")
42 ch <- "write,tag=tagVal fooField=5 1460912595"
43 pt := sf.GetPoint("foo_name", "s")
44 if string(pt.Name()) != "write" {
45 t.Errorf("expected: write\ngot: %v", string(pt.Name()))
46 }
47 if pt.Tags().GetString("tag") != "tagVal" {
48 t.Errorf("expected: tagVal\ngot: %v", pt.Tags().GetString("tag"))
49 }
50 fields, err := pt.Fields()
51 if err != nil {
52 t.Fatal(err)
53 }
54 if int(fields["fooField"].(float64)) != 5 {
55 t.Errorf("expected: 5\ngot: %v\n", fields["fooField"])
56 }
57 }