@@ -14,6 +14,59 @@ import (
14
14
"github.com/scylladb/scylla-manager/v3/pkg/testutils"
15
15
)
16
16
17
+ func TestMergeProgressStatus (t * testing.T ) {
18
+ testCases := []struct {
19
+ name string
20
+ dst , src ProgressStatus
21
+ expected ProgressStatus
22
+ }{
23
+ {
24
+ name : "empty + not_started(any) = not_started" ,
25
+ src : ProgressStatusNotStarted ,
26
+ expected : ProgressStatusNotStarted ,
27
+ },
28
+ {
29
+ name : "done + done = done" ,
30
+ src : ProgressStatusDone ,
31
+ dst : ProgressStatusDone ,
32
+ expected : ProgressStatusDone ,
33
+ },
34
+ {
35
+ name : "any + failed = failed" ,
36
+ dst : ProgressStatusDone ,
37
+ src : ProgressStatusFailed ,
38
+ expected : ProgressStatusFailed ,
39
+ },
40
+ {
41
+ name : "failed + any = failed" ,
42
+ dst : ProgressStatusFailed ,
43
+ src : ProgressStatusNotStarted ,
44
+ expected : ProgressStatusFailed ,
45
+ },
46
+ {
47
+ name : "done + in_progress = in_progress" ,
48
+ dst : ProgressStatusDone ,
49
+ src : ProgressStatusInProgress ,
50
+ expected : ProgressStatusInProgress ,
51
+ },
52
+ {
53
+ name : "not_started + in_progress = in_progress" ,
54
+ dst : ProgressStatusNotStarted ,
55
+ src : ProgressStatusInProgress ,
56
+ expected : ProgressStatusInProgress ,
57
+ },
58
+ }
59
+
60
+ for _ , tc := range testCases {
61
+ t .Run (tc .name , func (t * testing.T ) {
62
+ actual := mergeProgressStatus (tc .dst , tc .src )
63
+ if actual != tc .expected {
64
+ t .Fatalf ("Expected %q, but got %q" , tc .expected , actual )
65
+ }
66
+ })
67
+ }
68
+ }
69
+
17
70
func TestAggregateProgress (t * testing.T ) {
18
71
testCases := []struct {
19
72
name string
@@ -51,6 +104,11 @@ func TestAggregateProgress(t *testing.T) {
51
104
tableRows : "testdata/6.run_table_progress.json" ,
52
105
viewRows : "testdata/6.run_view_progress.json" ,
53
106
},
107
+ {
108
+ name : "Tables and views progress, status failed" ,
109
+ tableRows : "testdata/7.run_table_progress.json" ,
110
+ viewRows : "testdata/7.run_view_progress.json" ,
111
+ },
54
112
}
55
113
56
114
for _ , tc := range testCases {
0 commit comments