Skip to content
This repository has been archived by the owner on Feb 11, 2025. It is now read-only.

Commit

Permalink
Create UPPError object in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mchompalova committed Apr 10, 2020
1 parent 0df33bd commit c852111
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1508,8 +1508,11 @@ func TestUnHappyDeleteAnnotationsWhenRetrievingAnnotationsFails(t *testing.T) {
func TestUnHappyDeleteAnnotationsWhenNoAnnotationsFound(t *testing.T) {
rw := new(RWMock)
annAPI := new(AnnotationsAPIMock)

uppErr := annotations.NewUPPError(annotations.UPPNotFoundMsg, http.StatusNotFound, nil)

annAPI.On("GetAllButV2", mock.Anything, "83a201c6-60cd-11e7-91a7-502f7ee26895").
Return([]annotations.Annotation{}, errors.New(annotations.UPPNotFoundMsg))
Return([]annotations.Annotation{}, uppErr)
aug := new(AugmenterMock)

h := handler.New(rw, annAPI, nil, aug, time.Second)
Expand Down Expand Up @@ -1920,8 +1923,10 @@ func TestUnhappyAddAnnotationWhenNoAnnotationsFound(t *testing.T) {
annAPI := new(AnnotationsAPIMock)
aug := new(AugmenterMock)

uppErr := annotations.NewUPPError(annotations.UPPNotFoundMsg, http.StatusNotFound, nil)

rw.On("Write", mock.AnythingOfType("*context.valueCtx"), "83a201c6-60cd-11e7-91a7-502f7ee26895", &expectedCanonicalisedAnnotationsAfterAdditon, "").Return(mock.Anything, nil)
annAPI.On("GetAllButV2", mock.Anything, "83a201c6-60cd-11e7-91a7-502f7ee26895").Return(expectedAnnotations.Annotations, errors.New(annotations.UPPNotFoundMsg))
annAPI.On("GetAllButV2", mock.Anything, "83a201c6-60cd-11e7-91a7-502f7ee26895").Return(expectedAnnotations.Annotations, uppErr)

h := handler.New(rw, annAPI, annotations.NewCanonicalizer(annotations.NewCanonicalAnnotationSorter), aug, time.Second)
r := vestigo.NewRouter()
Expand Down Expand Up @@ -2330,8 +2335,10 @@ func TestUnhappyReplaceAnnotationWhenNoAnnotationsFound(t *testing.T) {
annAPI := new(AnnotationsAPIMock)
aug := new(AugmenterMock)

uppErr := annotations.NewUPPError(annotations.UPPNotFoundMsg, http.StatusNotFound, nil)

rw.On("Write", mock.AnythingOfType("*context.valueCtx"), "83a201c6-60cd-11e7-91a7-502f7ee26895", &expectedCanonicalisedAnnotationsAfterAdditon, "").Return(mock.Anything, nil)
annAPI.On("GetAllButV2", mock.Anything, "83a201c6-60cd-11e7-91a7-502f7ee26895").Return(expectedAnnotations.Annotations, errors.New(annotations.UPPNotFoundMsg))
annAPI.On("GetAllButV2", mock.Anything, "83a201c6-60cd-11e7-91a7-502f7ee26895").Return(expectedAnnotations.Annotations, uppErr)

h := handler.New(rw, annAPI, annotations.NewCanonicalizer(annotations.NewCanonicalAnnotationSorter), aug, time.Second)
r := vestigo.NewRouter()
Expand Down

0 comments on commit c852111

Please sign in to comment.