@@ -26,7 +26,6 @@ import (
26
26
27
27
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/plugin/kubernetes/config"
28
28
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/plugin/kubernetes/provider"
29
- "github.com/pipe-cd/pipecd/pkg/model"
30
29
"github.com/pipe-cd/pipecd/pkg/plugin/sdk"
31
30
)
32
31
@@ -914,13 +913,13 @@ spec:
914
913
}
915
914
}
916
915
917
- func TestDetermineStrategy (t * testing.T ) {
916
+ func Test_determineStrategy (t * testing.T ) {
918
917
tests := []struct {
919
918
name string
920
919
olds []string
921
920
news []string
922
921
workloadRefs []config.K8sResourceReference
923
- wantStrategy model .SyncStrategy
922
+ wantStrategy sdk .SyncStrategy
924
923
wantSummary string
925
924
}{
926
925
{
@@ -940,7 +939,7 @@ spec:
940
939
image: nginx:1.19.3
941
940
` ,
942
941
},
943
- wantStrategy : model . SyncStrategy_QUICK_SYNC ,
942
+ wantStrategy : sdk . SyncStrategyQuickSync ,
944
943
wantSummary : "Quick sync by applying all manifests because it was unable to find the currently running workloads" ,
945
944
},
946
945
{
@@ -960,7 +959,7 @@ spec:
960
959
` ,
961
960
},
962
961
news : []string {},
963
- wantStrategy : model . SyncStrategy_QUICK_SYNC ,
962
+ wantStrategy : sdk . SyncStrategyQuickSync ,
964
963
wantSummary : "Quick sync by applying all manifests because it was unable to find workloads in the new manifests" ,
965
964
},
966
965
{
@@ -993,7 +992,7 @@ spec:
993
992
image: nginx:1.19.4
994
993
` ,
995
994
},
996
- wantStrategy : model . SyncStrategy_PIPELINE ,
995
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
997
996
wantSummary : "Sync progressively because of updating image nginx from 1.19.3 to 1.19.4" ,
998
997
},
999
998
{
@@ -1042,7 +1041,7 @@ data:
1042
1041
key: new-value
1043
1042
` ,
1044
1043
},
1045
- wantStrategy : model . SyncStrategy_PIPELINE ,
1044
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1046
1045
wantSummary : "Sync progressively because ConfigMap my-config was updated" ,
1047
1046
},
1048
1047
{
@@ -1077,7 +1076,7 @@ spec:
1077
1076
image: nginx:1.19.3
1078
1077
` ,
1079
1078
},
1080
- wantStrategy : model . SyncStrategy_QUICK_SYNC ,
1079
+ wantStrategy : sdk . SyncStrategyQuickSync ,
1081
1080
wantSummary : "Quick sync to scale Deployment/nginx-deployment from 3 to 5" ,
1082
1081
},
1083
1082
{
@@ -1111,7 +1110,7 @@ spec:
1111
1110
image: nginx:1.19.3
1112
1111
` ,
1113
1112
},
1114
- wantStrategy : model . SyncStrategy_QUICK_SYNC ,
1113
+ wantStrategy : sdk . SyncStrategyQuickSync ,
1115
1114
wantSummary : "Quick sync to scale Deployment/nginx-deployment from <nil> to 1" ,
1116
1115
},
1117
1116
{
@@ -1145,7 +1144,7 @@ spec:
1145
1144
image: nginx:1.19.3
1146
1145
` ,
1147
1146
},
1148
- wantStrategy : model . SyncStrategy_QUICK_SYNC ,
1147
+ wantStrategy : sdk . SyncStrategyQuickSync ,
1149
1148
wantSummary : "Quick sync to scale Deployment/nginx-deployment from 1 to <nil>" ,
1150
1149
},
1151
1150
{
@@ -1206,7 +1205,7 @@ spec:
1206
1205
image: redis:6.0.9
1207
1206
` ,
1208
1207
},
1209
- wantStrategy : model . SyncStrategy_QUICK_SYNC ,
1208
+ wantStrategy : sdk . SyncStrategyQuickSync ,
1210
1209
wantSummary : "Quick sync to scale Deployment/nginx-deployment from 3 to 5, Deployment/redis-deployment from 2 to 4" ,
1211
1210
},
1212
1211
{
@@ -1243,7 +1242,7 @@ spec:
1243
1242
image: redis:6.0.10
1244
1243
` ,
1245
1244
},
1246
- wantStrategy : model . SyncStrategy_PIPELINE ,
1245
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1247
1246
wantSummary : "Sync progressively because of updating image nginx from 1.19.3 to 1.19.4, image redis from 6.0.9 to 6.0.10" ,
1248
1247
},
1249
1248
{
@@ -1280,7 +1279,7 @@ spec:
1280
1279
image: nginx:1.19.3
1281
1280
` ,
1282
1281
},
1283
- wantStrategy : model . SyncStrategy_PIPELINE ,
1282
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1284
1283
wantSummary : "Sync progressively because of updating image nginx:1.19.3 to redis:6.0.9, image redis:6.0.9 to nginx:1.19.3" ,
1285
1284
},
1286
1285
{
@@ -1343,7 +1342,7 @@ spec:
1343
1342
Name : "nginx-deployment" ,
1344
1343
},
1345
1344
},
1346
- wantStrategy : model . SyncStrategy_PIPELINE ,
1345
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1347
1346
wantSummary : "Sync progressively because of updating image nginx from 1.19.3 to 1.19.4" ,
1348
1347
},
1349
1348
{
@@ -1376,7 +1375,7 @@ spec:
1376
1375
image: nginx:1.19.3
1377
1376
` ,
1378
1377
},
1379
- wantStrategy : model . SyncStrategy_PIPELINE ,
1378
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1380
1379
wantSummary : "Sync progressively because pod template of workload nginx-deployment was changed" ,
1381
1380
},
1382
1381
{
@@ -1417,7 +1416,7 @@ spec:
1417
1416
memory: "1Gi"
1418
1417
` ,
1419
1418
},
1420
- wantStrategy : model . SyncStrategy_PIPELINE ,
1419
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1421
1420
wantSummary : "Sync progressively because pod template of workload nginx-deployment was changed" ,
1422
1421
},
1423
1422
{
@@ -1458,7 +1457,7 @@ spec:
1458
1457
image: nginx:1.19.3
1459
1458
` ,
1460
1459
},
1461
- wantStrategy : model . SyncStrategy_PIPELINE ,
1460
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1462
1461
wantSummary : "Sync progressively because 1 configmap/secret deleted" ,
1463
1462
},
1464
1463
{
@@ -1499,7 +1498,7 @@ spec:
1499
1498
image: nginx:1.19.3
1500
1499
` ,
1501
1500
},
1502
- wantStrategy : model . SyncStrategy_PIPELINE ,
1501
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1503
1502
wantSummary : "Sync progressively because 1 configmap/secret deleted" ,
1504
1503
},
1505
1504
{
@@ -1540,7 +1539,7 @@ data:
1540
1539
key: value
1541
1540
` ,
1542
1541
},
1543
- wantStrategy : model . SyncStrategy_PIPELINE ,
1542
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1544
1543
wantSummary : "Sync progressively because new 1 configmap/secret added" ,
1545
1544
},
1546
1545
{
@@ -1581,7 +1580,7 @@ data:
1581
1580
key: dmFsdWU=
1582
1581
` ,
1583
1582
},
1584
- wantStrategy : model . SyncStrategy_PIPELINE ,
1583
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1585
1584
wantSummary : "Sync progressively because new 1 configmap/secret added" ,
1586
1585
},
1587
1586
{
@@ -1630,7 +1629,7 @@ data:
1630
1629
key: new-value
1631
1630
` ,
1632
1631
},
1633
- wantStrategy : model . SyncStrategy_PIPELINE ,
1632
+ wantStrategy : sdk . SyncStrategyPipelineSync ,
1634
1633
wantSummary : "Sync progressively because ConfigMap old-config was deleted" ,
1635
1634
},
1636
1635
{
@@ -1664,7 +1663,7 @@ spec:
1664
1663
image: nginx:1.19.3
1665
1664
` ,
1666
1665
},
1667
- wantStrategy : model . SyncStrategy_QUICK_SYNC ,
1666
+ wantStrategy : sdk . SyncStrategyQuickSync ,
1668
1667
wantSummary : "Quick sync by applying all manifests" ,
1669
1668
},
1670
1669
{
@@ -1697,7 +1696,7 @@ spec:
1697
1696
image: nginx:1.19.3
1698
1697
` ,
1699
1698
},
1700
- wantStrategy : model . SyncStrategy_QUICK_SYNC ,
1699
+ wantStrategy : sdk . SyncStrategyQuickSync ,
1701
1700
wantSummary : "Quick sync by applying all manifests" ,
1702
1701
},
1703
1702
}
@@ -1713,7 +1712,7 @@ spec:
1713
1712
}
1714
1713
logger := zap .NewNop ()
1715
1714
gotStrategy , gotSummary := determineStrategy (oldManifests , newManifests , tt .workloadRefs , logger )
1716
- assert .Equal (t , tt .wantStrategy . String () , gotStrategy . String () )
1715
+ assert .Equal (t , tt .wantStrategy , gotStrategy )
1717
1716
assert .Equal (t , tt .wantSummary , gotSummary )
1718
1717
})
1719
1718
}
0 commit comments