master
go 39 lines 870 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package metrix
4
5 import "testing"
6
7 func TestLifecycleStoreScenarios(t *testing.T) {
8 tests := map[string]struct {
9 run func(t *testing.T)
10 }{
11 "double BeginCycle panics": {
12 run: func(t *testing.T) {
13 s := NewCollectorStore()
14 cc := cycleController(t, s)
15 cc.BeginCycle()
16 expectPanic(t, func() { cc.BeginCycle() })
17 cc.AbortCycle()
18 },
19 },
20 "CommitCycleSuccess without BeginCycle panics": {
21 run: func(t *testing.T) {
22 s := NewCollectorStore()
23 cc := cycleController(t, s)
24 expectPanic(t, func() { cc.CommitCycleSuccess() })
25 },
26 },
27 "AbortCycle without BeginCycle panics": {
28 run: func(t *testing.T) {
29 s := NewCollectorStore()
30 cc := cycleController(t, s)
31 expectPanic(t, func() { cc.AbortCycle() })
32 },
33 },
34 }
35
36 for name, tc := range tests {
37 t.Run(name, tc.run)
38 }
39 }