Change ERR_KV to ERR_EX for ‘record already exists’ errors

This commit is contained in:
Tobie Morgan Hitchcock 2018-04-23 09:12:00 +01:00
parent 1f30035899
commit 27a5f785fd
3 changed files with 9 additions and 9 deletions

View file

@ -64,7 +64,7 @@ func TestCreate(t *testing.T) {
So(res, ShouldHaveLength, 3)
So(res[1].Result, ShouldHaveLength, 1)
So(res[2].Result, ShouldHaveLength, 0)
So(res[2].Status, ShouldEqual, "ERR_KV")
So(res[2].Status, ShouldEqual, "ERR_EX")
So(res[2].Detail, ShouldEqual, "Database record 'person:test' already exists")
})
@ -272,15 +272,15 @@ func TestCreate(t *testing.T) {
So(err, ShouldBeNil)
So(res, ShouldHaveLength, 8)
So(res[1].Result, ShouldHaveLength, 1)
So(res[2].Status, ShouldEqual, "ERR_KV")
So(res[2].Status, ShouldEqual, "ERR_EX")
So(res[2].Detail, ShouldEqual, "Database record 'person:1' already exists")
So(res[3].Status, ShouldEqual, "ERR_KV")
So(res[3].Status, ShouldEqual, "ERR_EX")
So(res[3].Detail, ShouldEqual, "Database record 'person:1' already exists")
So(res[4].Status, ShouldEqual, "ERR_KV")
So(res[4].Status, ShouldEqual, "ERR_EX")
So(res[4].Detail, ShouldEqual, "Database record 'person:1' already exists")
So(res[5].Status, ShouldEqual, "ERR_KV")
So(res[5].Status, ShouldEqual, "ERR_EX")
So(res[5].Detail, ShouldEqual, "Database record 'person:1' already exists")
So(res[6].Status, ShouldEqual, "ERR_KV")
So(res[6].Status, ShouldEqual, "ERR_EX")
So(res[6].Detail, ShouldEqual, "Database record 'person:1' already exists")
So(res[7].Result, ShouldHaveLength, 1)

View file

@ -488,7 +488,7 @@ func status(e error) (s string) {
case *PermsError:
return "ERR_PE"
case *ExistError:
return "ERR_KV"
return "ERR_EX"
case *FieldError:
return "ERR_FD"
case *IndexError:

View file

@ -146,7 +146,7 @@ func TestInsert(t *testing.T) {
So(res[2].Result, ShouldHaveLength, 1)
So(data.Consume(res[2].Result[0]).Get("login").Data(), ShouldEqual, "joe")
So(data.Consume(res[2].Result[0]).Get("meta.id").Data(), ShouldEqual, 360)
So(res[3].Status, ShouldEqual, "ERR_KV")
So(res[3].Status, ShouldEqual, "ERR_EX")
So(res[3].Detail, ShouldEqual, "Database record 'users:360' already exists")
So(res[4].Result, ShouldHaveLength, 1)
So(data.Consume(res[4].Result[0]).Get("login").Data(), ShouldEqual, "joe")
@ -203,7 +203,7 @@ func TestInsert(t *testing.T) {
So(data.Consume(res[2].Result[1]).Get("meta.id").Data(), ShouldEqual, 200)
So(data.Consume(res[2].Result[2]).Get("login").Data(), ShouldEqual, "tester")
So(data.Consume(res[2].Result[2]).Get("meta.id").Data(), ShouldEqual, "test")
So(res[3].Status, ShouldEqual, "ERR_KV")
So(res[3].Status, ShouldEqual, "ERR_EX")
So(res[4].Result, ShouldHaveLength, 3)
So(data.Consume(res[4].Result[0]).Get("login").Data(), ShouldEqual, "mike")
So(data.Consume(res[4].Result[0]).Get("meta.id").Data(), ShouldEqual, 200)