| 90 | } |
| 91 | |
| 92 | func TestBEGIN(t *testing.T) { |
| 93 | |
| 94 | tests := map[string]struct { |
| 95 | name string |
| 96 | typeID string |
| 97 | ID string |
| 98 | msSince int |
| 99 | expected string |
| 100 | }{ |
| 101 | "without msSince": { |
| 102 | typeID: "system", |
| 103 | ID: "cpu", |
| 104 | msSince: 0, |
| 105 | expected: "BEGIN 'system.cpu'\n", |
| 106 | }, |
| 107 | "with msSince": { |
| 108 | typeID: "system", |
| 109 | ID: "cpu", |
| 110 | msSince: 1000, |
| 111 | expected: "BEGIN 'system.cpu' 1000\n", |
| 112 | }, |
| 113 | } |
| 114 | |
| 115 | for name, test := range tests { |
| 116 | t.Run(name, func(t *testing.T) { |
| 117 | w := &bytes.Buffer{} |
| 118 | api := New(w) |
| 119 | |
| 120 | api.BEGIN(test.typeID, test.ID, test.msSince) |
| 121 | |
| 122 | require.Equal(t, test.expected, w.String()) |
| 123 | }) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | func TestSET(t *testing.T) { |
| 128 | w := &bytes.Buffer{} |