diff --git a/go.mod b/go.mod index f0d9ce1..fea0d24 100644 --- a/go.mod +++ b/go.mod @@ -1,24 +1,22 @@ module github.com/Financial-Times/publish-failure-resolver-go -go 1.13 +go 1.17 require ( github.com/Financial-Times/transactionid-utils-go v0.2.0 - github.com/Financial-Times/uuid-utils-go v0.0.0-20170516110427-e22658edd0f1 github.com/Financial-Times/workbalancer v0.0.0-20180209121015-1c97e65a6e37 - github.com/davecgh/go-spew v1.1.0 // indirect github.com/jawher/mow.cli v1.0.1 - github.com/onsi/ginkgo v1.12.0 // indirect - github.com/onsi/gomega v1.9.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/sirupsen/logrus v1.0.3 - github.com/stretchr/objx v0.1.1 // indirect github.com/stretchr/testify v1.2.2-0.20180206082539-be8372ae8ec5 - github.com/willf/bitset v1.1.4-0.20170905002639-1a37ad96e8c1 // indirect +) + +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.1.1 // indirect golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect golang.org/x/net v0.0.0-20200226121028-0de0cce0169b // indirect - golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect - golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect + golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e // indirect gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect ) diff --git a/go.sum b/go.sum index 1c0c2aa..ac775a9 100644 --- a/go.sum +++ b/go.sum @@ -1,25 +1,11 @@ github.com/Financial-Times/transactionid-utils-go v0.2.0 h1:YcET5Hd1fUGWWpQSVszYUlAc15ca8tmjRetUuQKRqEQ= github.com/Financial-Times/transactionid-utils-go v0.2.0/go.mod h1:tPAcAFs/dR6Q7hBDGNyUyixHRvg/n9NW/JTq8C58oZ0= -github.com/Financial-Times/uuid-utils-go v0.0.0-20170516110427-e22658edd0f1 h1:FXM7cqqPyGh2QZ8BRJA16Gr65/+/91KEFSPKyRM+Nd8= -github.com/Financial-Times/uuid-utils-go v0.0.0-20170516110427-e22658edd0f1/go.mod h1:i62wLwNq+NmRCQpZS5BLTKsOVYsTOxs9bSx7FgtxXwM= github.com/Financial-Times/workbalancer v0.0.0-20180209121015-1c97e65a6e37 h1:u4xUt1ofJbuu6gYgtYktz5Nizv9y/VH4mbSXQvbOaF4= github.com/Financial-Times/workbalancer v0.0.0-20180209121015-1c97e65a6e37/go.mod h1:+0qdJdhJIGb4M1mlduK9cWPybFcE2gqnX5BixV68LP4= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jawher/mow.cli v1.0.1 h1:H47gmvfl3DlNEHfGmEK+Txm/yxyOzNE86CcSH4DOaec= github.com/jawher/mow.cli v1.0.1/go.mod h1:5hQj2V8g+qYmLUVWqu4Wuja1pI57M83EChYLVZ0sMKk= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU= -github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= -github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.0.3 h1:B5C/igNWoiULof20pKfY4VntcIPqKuwEmoLZrabbUrc= @@ -28,40 +14,18 @@ github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2-0.20180206082539-be8372ae8ec5 h1:BkVDDzWTIqbCmmFsfYbau/YqI3BjmlzEn/aENEiDtKk= github.com/stretchr/testify v1.2.2-0.20180206082539-be8372ae8ec5/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/willf/bitset v1.1.4-0.20170905002639-1a37ad96e8c1 h1:6YAC9w0ne4nSsR9mdO1Ekvdhz4KfKOtao8LXdctGTgQ= -github.com/willf/bitset v1.1.4-0.20170905002639-1a37ad96e8c1/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/republisher/collection_metadata.go b/pkg/republisher/collection_metadata.go index 0de290b..ce573f2 100644 --- a/pkg/republisher/collection_metadata.go +++ b/pkg/republisher/collection_metadata.go @@ -18,12 +18,6 @@ type CollectionMetadata struct { } var DefaultCollections = Collections{ - "wordpress": { - name: "wordpress", - defaultOriginSystemID: "http://cmdb.ft.com/systems/wordpress", - notifierApp: CmsNotifier, - scope: ScopeContent, - }, "universal-content": { name: "universal-content", defaultOriginSystemID: "http://cmdb.ft.com/systems/cct", diff --git a/pkg/republisher/uuid_republisher_test.go b/pkg/republisher/uuid_republisher_test.go index 3acecec..0349ef7 100644 --- a/pkg/republisher/uuid_republisher_test.go +++ b/pkg/republisher/uuid_republisher_test.go @@ -10,12 +10,6 @@ import ( ) var testCollections = Collections{ - "wordpress": { - name: "wordpress", - defaultOriginSystemID: "wordpress", - notifierApp: CmsNotifier, - scope: ScopeContent, - }, "video": { name: "video", defaultOriginSystemID: "next-video-editor", @@ -51,7 +45,7 @@ func TestOkAndSoftErrors_Ok(t *testing.T) { msg := OKMsg{ uuid: "b3ec9282-1073-46ad-9d44-144dad7fe956", tid: "prefix1", - collectionName: "wordpress", + collectionName: "universal-content", collectionOriginSystemID: "cct", sizeBytes: 1024, notifierAppName: "cms-notifier", @@ -69,16 +63,20 @@ func TestOkAndSoftErrors_Ok(t *testing.T) { expectedMsgs := []*OKMsg{&msg, &msg2} var nilMsg *OKMsg mockedUCRepublisher.On("RepublishUUIDFromCollection", "b3ec9282-1073-46ad-9d44-144dad7fe956", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["pac-metadata"]).Return(&msg2, true, nil) - mockedUCRepublisher.On("RepublishUUIDFromCollection", "b3ec9282-1073-46ad-9d44-144dad7fe956", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["wordpress"]).Return(&msg, true, nil) - mockedUCRepublisher.On("RepublishUUIDFromCollection", "b3ec9282-1073-46ad-9d44-144dad7fe956", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["universal-content"]).Return(nilMsg, false, nil) - mockedUCRepublisher.On("RepublishUUIDFromCollection", "b3ec9282-1073-46ad-9d44-144dad7fe956", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["video"]).Return(nilMsg, false, fmt.Errorf("test error let's say 401")) + mockedUCRepublisher.On("RepublishUUIDFromCollection", "b3ec9282-1073-46ad-9d44-144dad7fe956", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["universal-content"]).Return(&msg, true, nil) + + mockedUCRepublisher.On("RepublishUUIDFromCollection", "b3ec9282-1073-46ad-9d44-144dad7fe956", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix2") }), testCollections["universal-content"]).Return(nilMsg, false, nil) + mockedUCRepublisher.On("RepublishUUIDFromCollection", "b3ec9282-1073-46ad-9d44-144dad7fe956", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix2") }), testCollections["video"]).Return(nilMsg, false, fmt.Errorf("test error let's say 401")) msgs, errs := republisher.Republish("b3ec9282-1073-46ad-9d44-144dad7fe956", "prefix1", "both") + msgs2, errs2 := republisher.Republish("b3ec9282-1073-46ad-9d44-144dad7fe956", "prefix2", "content") assert.Equal(t, 2, len(msgs)) - assert.Equal(t, 1, len(errs)) + assert.Equal(t, 0, len(errs)) + assert.Equal(t, 0, len(msgs2)) + assert.Equal(t, 1, len(errs2)) assert.ElementsMatch(t, msgs, expectedMsgs) - assert.Equal(t, fmt.Errorf("error publishing test error let's say 401"), errs[0]) + assert.Equal(t, fmt.Errorf("error publishing test error let's say 401"), errs2[0]) } func TestNotScoped_Ok(t *testing.T) { @@ -87,12 +85,12 @@ func TestNotScoped_Ok(t *testing.T) { msg := OKMsg{ uuid: "b3ec9282-1073-46ad-9d44-144dad7fe956", tid: "prefix1", - collectionName: "wordpress", + collectionName: "universal-content", collectionOriginSystemID: "cct", sizeBytes: 1024, notifierAppName: "cms-notifier", } - mockedUCRepublisher.On("RepublishUUIDFromCollection", "b3ec9282-1073-46ad-9d44-144dad7fe956", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["wordpress"]).Return(&msg, true, nil) + mockedUCRepublisher.On("RepublishUUIDFromCollection", "b3ec9282-1073-46ad-9d44-144dad7fe956", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["universal-content"]).Return(&msg, true, nil) msgs, errs := r.Republish("b3ec9282-1073-46ad-9d44-144dad7fe956", "prefix1", "metadata") @@ -100,113 +98,6 @@ func TestNotScoped_Ok(t *testing.T) { assert.Equal(t, 0, len(errs)) } -func TestUUIDInUCAndWordpressRepublishedInUC(t *testing.T) { - mockedUCRepublisher := new(mockUCRepublisher) - msg := OKMsg{ - uuid: "64bc4319-cd22-43e9-8b12-358622d7a5ba", - tid: "prefix1tid_123", - collectionName: "universal-content", - collectionOriginSystemID: "cct", - sizeBytes: 1024, - notifierAppName: "cms-notifier", - } - - msg2 := OKMsg{ - uuid: "b3ec9282-1073-46ad-9d44-144dad7fe956", - tid: "prefix1", - collectionName: "pac-metadata", - collectionOriginSystemID: "http://cmdb.ft.com/systems/pac", - sizeBytes: 1024, - notifierAppName: "cmsMetadataNotifier", - } - - msg3 := OKMsg{ - uuid: "b3ec9282-1073-46ad-9d44-144dad7fe956", - tid: "prefix1", - collectionName: "wordpress", - collectionOriginSystemID: "cct", - sizeBytes: 1024, - notifierAppName: "cms-notifier", - } - - var nilMsg *OKMsg - mockedUCRepublisher.On("RepublishUUIDFromCollection", "64bc4319-cd22-43e9-8b12-358622d7a5ba", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["universal-content"]).Return(&msg, true, nil) - mockedUCRepublisher.On("RepublishUUIDFromCollection", "64bc4319-cd22-43e9-8b12-358622d7a5ba", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["pac-metadata"]).Return(&msg2, true, nil) - mockedUCRepublisher.On("RepublishUUIDFromCollection", "64bc4319-cd22-43e9-8b12-358622d7a5ba", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["wordpress"]).Return(msg3, true, nil) - mockedUCRepublisher.On("RepublishUUIDFromCollection", "64bc4319-cd22-43e9-8b12-358622d7a5ba", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["video"]).Return(nilMsg, false, nil) - r := NewNotifyingUUIDRepublisher(mockedUCRepublisher, testCollections) - - msgs, errs := r.Republish("64bc4319-cd22-43e9-8b12-358622d7a5ba", "prefix1", ScopeBoth) - - assert.Equal(t, 2, len(msgs)) - assert.Equal(t, 0, len(errs)) - for _, m := range msgs { - switch m.collectionName { - case msg.collectionName: - assert.Equal(t, msg, *m) - case msg2.collectionName: - assert.Equal(t, msg2, *m) - default: - assert.Fail(t, fmt.Sprintf("%s should not be republished", m.collectionName)) - } - } - - mockedUCRepublisher.On("RepublishUUIDFromCollection", "64bc4319-cd22-43e9-8b12-358622d7a5ba", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["pac-metadata"]).Return(nilMsg, false, nil) - msgs, errs = r.Republish("64bc4319-cd22-43e9-8b12-358622d7a5ba", "prefix1", ScopeContent) - - assert.Equal(t, 1, len(msgs)) - assert.Equal(t, 0, len(errs)) - assert.Equal(t, msg, *msgs[0]) -} - -func TestUUIDInWordpressNotInUC(t *testing.T) { - mockedUCRepublisher := new(mockUCRepublisher) - r := NewNotifyingUUIDRepublisher(mockedUCRepublisher, testCollections) - msg := OKMsg{ - uuid: "64bc4319-cd22-43e9-8b12-358622d7a5ba", - tid: "prefix1tid_123", - collectionName: "wordpress", - collectionOriginSystemID: "cct", - sizeBytes: 1024, - notifierAppName: "cms-notifier", - } - msg2 := OKMsg{ - uuid: "b3ec9282-1073-46ad-9d44-144dad7fe956", - tid: "prefix1", - collectionName: "pac-metadata", - collectionOriginSystemID: "http://cmdb.ft.com/systems/pac", - sizeBytes: 1024, - notifierAppName: "cmsMetadataNotifier", - } - - var nilMsg *OKMsg - mockedUCRepublisher.On("RepublishUUIDFromCollection", "64bc4319-cd22-43e9-8b12-358622d7a5ba", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["pac-metadata"]).Return(&msg2, true, nil) - mockedUCRepublisher.On("RepublishUUIDFromCollection", "64bc4319-cd22-43e9-8b12-358622d7a5ba", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["universal-content"]).Return(nilMsg, false, nil) - mockedUCRepublisher.On("RepublishUUIDFromCollection", "64bc4319-cd22-43e9-8b12-358622d7a5ba", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["wordpress"]).Return(&msg, true, nil) - mockedUCRepublisher.On("RepublishUUIDFromCollection", "64bc4319-cd22-43e9-8b12-358622d7a5ba", mock.MatchedBy(func(tid string) bool { return strings.HasPrefix(tid, "prefix1") }), testCollections["video"]).Return(nilMsg, false, nil) - - msgs, errs := r.Republish("64bc4319-cd22-43e9-8b12-358622d7a5ba", "prefix1", ScopeBoth) - - assert.Equal(t, 2, len(msgs)) - assert.Equal(t, 0, len(errs)) - for _, m := range msgs { - switch m.collectionName { - case msg.collectionName: - assert.Equal(t, msg, *m) - case msg2.collectionName: - assert.Equal(t, msg2, *m) - default: - assert.Fail(t, fmt.Sprintf("%s should not be republished", m.collectionName)) - } - } - - msgs, errs = r.Republish("64bc4319-cd22-43e9-8b12-358622d7a5ba", "prefix1", ScopeContent) - - assert.Equal(t, 1, len(msgs)) - assert.Equal(t, 0, len(errs)) - assert.Equal(t, msg, *msgs[0]) -} - type mockUCRepublisher struct { mock.Mock }