@@ -33,12 +33,16 @@ const (
3333 datasetValidID = "found"
3434)
3535
36+ var (
37+ errTest = errors .New ("unexpected error" )
38+ )
39+
3640func TestStaticDatasetValidatorWithExternal (t * testing.T ) {
3741 zebedeeMock := & clientMocks.ZebedeeClientMock {
3842 GetPageDataFunc : func (ctx context.Context , userAuthToken , collectionID , lang , path string ) (zebedee.PageData , error ) {
3943 switch path {
4044 case zebedeeErrorPath :
41- return zebedee.PageData {}, errors . New ( "unexpected error" )
45+ return zebedee.PageData {}, errTest
4246 case zebedeeValidPath :
4347 return zebedee.PageData {
4448 Type : zebedee .PageTypeDatasetLandingPage ,
@@ -71,7 +75,7 @@ func TestStaticDatasetValidatorWithExternal(t *testing.T) {
7175 GetDatasetFunc : func (ctx context.Context , headers datasetSDK.Headers , datasetID string ) (datasetModels.Dataset , error ) {
7276 switch datasetID {
7377 case datasetErrorID :
74- return datasetModels.Dataset {}, errors . New ( "unexpected error" )
78+ return datasetModels.Dataset {}, errTest
7579 case datasetValidID :
7680 return datasetModels.Dataset {}, nil
7781 case datasetNotFoundID :
@@ -129,6 +133,7 @@ func TestStaticDatasetValidatorWithExternal(t *testing.T) {
129133
130134 Convey ("Then an error should be returned" , func () {
131135 So (err , ShouldNotBeNil )
136+ So (err , ShouldEqual , appErrors .ErrSourceIDValidation )
132137
133138 Convey ("And the title should be empty" , func () {
134139 So (title , ShouldEqual , "" )
@@ -137,14 +142,15 @@ func TestStaticDatasetValidatorWithExternal(t *testing.T) {
137142 })
138143 })
139144
140- Convey ("Given a zebedee source ID that returns not found error" , t , func () {
145+ Convey ("Given a zebedee source ID that returns a not found error" , t , func () {
141146 validator := domain.StaticDatasetValidator {}
142147
143148 Convey ("When the source is validated" , func () {
144149 title , err := validator .ValidateSourceIDWithExternal (ctx , zebedeeNotFoundPath , & mockClientlist , testUserAuthToken )
145150
146151 Convey ("Then an error should be returned" , func () {
147152 So (err , ShouldNotBeNil )
153+ So (err , ShouldEqual , appErrors .ErrSourceDoesNotExist )
148154
149155 Convey ("And the title should be empty" , func () {
150156 So (title , ShouldEqual , "" )
@@ -161,6 +167,7 @@ func TestStaticDatasetValidatorWithExternal(t *testing.T) {
161167
162168 Convey ("Then an error should be returned" , func () {
163169 So (err , ShouldNotBeNil )
170+ So (err , ShouldEqual , appErrors .ErrSourceDataTypeInvalid )
164171
165172 Convey ("And the title should be empty" , func () {
166173 So (title , ShouldEqual , "" )
@@ -189,6 +196,7 @@ func TestStaticDatasetValidatorWithExternal(t *testing.T) {
189196
190197 Convey ("Then an error should be returned" , func () {
191198 So (err , ShouldNotBeNil )
199+ So (err , ShouldEqual , appErrors .ErrTargetAlreadyExists )
192200 })
193201 })
194202 })
@@ -201,6 +209,7 @@ func TestStaticDatasetValidatorWithExternal(t *testing.T) {
201209
202210 Convey ("Then an error should be returned" , func () {
203211 So (err , ShouldNotBeNil )
212+ So (err , ShouldEqual , appErrors .ErrTargetIDValidation )
204213 })
205214 })
206215 })
0 commit comments