@@ -26,11 +26,60 @@ func TestPayments(t *testing.T) {
26
26
27
27
testInstallConnectors (t , store )
28
28
testCreatePayments (t , store )
29
+ testCreatePaymentsSameReferenceButDifferentConnectorID (t , store )
29
30
testUpdatePayment (t , store )
30
31
testUninstallConnectors (t , store )
31
32
testPaymentsDeletedAfterConnectorUninstall (t , store )
32
33
}
33
34
35
+ func testCreatePaymentsSameReferenceButDifferentConnectorID (t * testing.T , store * storage.Storage ) {
36
+ id1 := & models.PaymentID {
37
+ PaymentReference : models.PaymentReference {
38
+ Reference : "test-same-reference" ,
39
+ Type : models .PaymentTypePayOut ,
40
+ },
41
+ ConnectorID : connectorID ,
42
+ }
43
+ p1 := & models.Payment {
44
+ ID : * id1 ,
45
+ CreatedAt : p1T ,
46
+ Reference : "test-same-reference" ,
47
+ Amount : big .NewInt (100 ),
48
+ ConnectorID : connectorID ,
49
+ Type : models .PaymentTypePayOut ,
50
+ Status : models .PaymentStatusSucceeded ,
51
+ Scheme : models .PaymentSchemeCardVisa ,
52
+ Asset : models .Asset ("USD/2" ),
53
+ }
54
+
55
+ ids , err := store .UpsertPayments (context .Background (), []* models.Payment {p1 })
56
+ require .NoError (t , err )
57
+ require .Len (t , ids , 1 )
58
+
59
+ id2 := & models.PaymentID {
60
+ PaymentReference : models.PaymentReference {
61
+ Reference : "test-same-reference2" ,
62
+ Type : models .PaymentTypePayOut ,
63
+ },
64
+ ConnectorID : connectorID2 ,
65
+ }
66
+ p2 := & models.Payment {
67
+ ID : * id2 ,
68
+ CreatedAt : p1T ,
69
+ Reference : "test-same-reference2" ,
70
+ Amount : big .NewInt (100 ),
71
+ ConnectorID : connectorID2 ,
72
+ Type : models .PaymentTypePayOut ,
73
+ Status : models .PaymentStatusSucceeded ,
74
+ Scheme : models .PaymentSchemeCardVisa ,
75
+ Asset : models .Asset ("USD/2" ),
76
+ }
77
+
78
+ ids , err = store .UpsertPayments (context .Background (), []* models.Payment {p2 })
79
+ require .NoError (t , err )
80
+ require .Len (t , ids , 1 )
81
+ }
82
+
34
83
func testCreatePayments (t * testing.T , store * storage.Storage ) {
35
84
p1ID = & models.PaymentID {
36
85
PaymentReference : models.PaymentReference {
0 commit comments