-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Avoid calling the document store for image sets.
Using the document store to discover image model UUIDs for republishing is only applicable if the image set has been published successfully to at least one environment. Although simply generating the alternative UUID when it's not found directly may seem less robust, the probability that we find and republish the wrong piece of content in this case is vanishingly small.
- Loading branch information
Keith Hatton
committed
Feb 12, 2018
1 parent
a1dca23
commit 66154eb
Showing
6 changed files
with
74 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/Financial-Times/uuid-utils-go" | ||
) | ||
|
||
type imageSetUUIDResolver interface { | ||
GetImageSetsModelUUID(setUUID, tid string) (found bool, modelUUID string, err error) | ||
} | ||
|
||
type uuidImageSetResolver struct { | ||
} | ||
|
||
func newUUIDImageSetResolver() imageSetUUIDResolver { | ||
return &uuidImageSetResolver{} | ||
} | ||
|
||
func (r *uuidImageSetResolver) GetImageSetsModelUUID(setUUID, tid string) (found bool, modelUUID string, err error) { | ||
requestedUUID, _ := uuidutils.NewUUIDFromString(setUUID) | ||
derivedUUID, _ := uuidutils.NewUUIDDeriverWith(uuidutils.IMAGE_SET).From(requestedUUID) | ||
return true, derivedUUID.String(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestUuidImageSetResolver(t *testing.T) { | ||
r := newUUIDImageSetResolver() | ||
|
||
imageSetUUID := "9f365884-0c25-11e8-24ad-bec2279df517" | ||
|
||
found, imageModelUUID, err := r.GetImageSetsModelUUID(imageSetUUID, "tid_test") | ||
assert.True(t, found, "found image model UUID") | ||
assert.Equal(t, "9f365884-0c25-11e8-bacb-2958fde95e5e", imageModelUUID, "image model UUID") | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters