improving get method and its test
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
❯ grpcurl -plaintext -d '{"id": 1}' localhost:50051 multieko2.Adresar/GetAdresar
|
||||
❯ grpcurl -plaintext -d '{"id": 1}' localhost:50051 multieko2.adresar.Adresar/GetAdresar
|
||||
{
|
||||
"id": "1",
|
||||
"firma": "Updated Firma",
|
||||
@@ -17,7 +17,7 @@
|
||||
"skladu": "Updated Skladu",
|
||||
"fax": "Updated Fax"
|
||||
}
|
||||
❯ grpcurl -plaintext -d '{"id": 2}' localhost:50051 multieko2.Adresar/GetAdresar
|
||||
❯ grpcurl -plaintext -d '{"id": 2}' localhost:50051 multieko2.adresar.Adresar/GetAdresar
|
||||
{
|
||||
"id": "2",
|
||||
"firma": "asdfasf",
|
||||
@@ -36,15 +36,15 @@
|
||||
"skladu": "f",
|
||||
"fax": " "
|
||||
}
|
||||
❯ grpcurl -plaintext -d '{"id": 1}' localhost:50051 multieko2.Adresar/DeleteAdresar
|
||||
❯ grpcurl -plaintext -d '{"id": 1}' localhost:50051 multieko2.adresar.Adresar/DeleteAdresar
|
||||
{
|
||||
"success": true
|
||||
}
|
||||
❯ grpcurl -plaintext -d '{"id": 1}' localhost:50051 multieko2.Adresar/GetAdresar
|
||||
❯ grpcurl -plaintext -d '{"id": 1}' localhost:50051 multieko2.adresar.Adresar/GetAdresar
|
||||
ERROR:
|
||||
Code: NotFound
|
||||
Message: no rows returned by a query that expected to return at least one row
|
||||
❯ grpcurl -plaintext -d '{"id": 2}' localhost:50051 multieko2.Adresar/GetAdresar
|
||||
❯ grpcurl -plaintext -d '{"id": 2}' localhost:50051 multieko2.adresar.Adresar/GetAdresar
|
||||
{
|
||||
"id": "2",
|
||||
"firma": "asdfasf",
|
||||
@@ -80,7 +80,7 @@ ERROR:
|
||||
"telefon": "New Telefon",
|
||||
"skladu": "New Skladu",
|
||||
"fax": "New Fax"
|
||||
}' localhost:50051 multieko2.Adresar/PostAdresar
|
||||
}' localhost:50051 multieko2.adresar.Adresar/PostAdresar
|
||||
{
|
||||
"id": "43",
|
||||
"firma": "New Firma",
|
||||
@@ -116,7 +116,7 @@ ERROR:
|
||||
"telefon": "Updated Telefon",
|
||||
"skladu": "Updated Skladu",
|
||||
"fax": "Updated Fax"
|
||||
}' localhost:50051 multieko2.Adresar/PutAdresar
|
||||
}' localhost:50051 multieko2.adresar.Adresar/PutAdresar
|
||||
{
|
||||
"id": "43",
|
||||
"firma": "Updated Firma",
|
||||
@@ -135,7 +135,7 @@ ERROR:
|
||||
"skladu": "Updated Skladu",
|
||||
"fax": "Updated Fax"
|
||||
}
|
||||
❯ grpcurl -plaintext -d '{"id": 43}' localhost:50051 multieko2.Adresar/GetAdresar
|
||||
❯ grpcurl -plaintext -d '{"id": 43}' localhost:50051 multieko2.adresar.Adresar/GetAdresar
|
||||
{
|
||||
"id": "43",
|
||||
"firma": "Updated Firma",
|
||||
|
||||
@@ -1,31 +1,27 @@
|
||||
# TOTAL items in the adresar
|
||||
❯ grpcurl -plaintext localhost:50051 multieko2.Adresar/GetAdresarCount
|
||||
{
|
||||
"count": "43"
|
||||
}
|
||||
|
||||
# Item at this count. If there are 43 items, number 1 is the first item
|
||||
❯ grpcurl -plaintext -d '{"position": 1}' localhost:50051 multieko2.Adresar/GetAdresarByPosition
|
||||
# TOTAL items in the adresar
|
||||
❯ grpcurl -plaintext localhost:50051 multieko2.adresar.Adresar/GetAdresarCount
|
||||
{
|
||||
"id": "2",
|
||||
"firma": "asdfasf",
|
||||
"kz": " ",
|
||||
"drc": " ",
|
||||
"ulica": " ",
|
||||
"psc": "sdfasdf",
|
||||
"count": "5"
|
||||
}
|
||||
# Item at this count. If there are 43 items, number 1 is the first item
|
||||
❯ grpcurl -plaintext -d '{"position": 1}' localhost:50051 multieko2.adresar.Adresar/GetAdresarByPosition
|
||||
{
|
||||
"id": "1",
|
||||
"firma": "ks555",
|
||||
"kz": "f",
|
||||
"drc": "asdf",
|
||||
"ulica": "as",
|
||||
"psc": "f",
|
||||
"mesto": "asf",
|
||||
"stat": "as",
|
||||
"banka": "df",
|
||||
"ucet": "asf",
|
||||
"skladm": "f",
|
||||
"ico": "f",
|
||||
"kontakt": "f",
|
||||
"telefon": "f",
|
||||
"skladu": "f",
|
||||
"fax": " "
|
||||
"banka": "fa",
|
||||
"telefon": "a",
|
||||
"skladu": "fd",
|
||||
"fax": "asf"
|
||||
}
|
||||
# Item fetched by id. The first item was created and removed, therefore number 1 in ids doenst exists, since first to exist now has number 2
|
||||
❯ grpcurl -plaintext -d '{"id": 1}' localhost:50051 multieko2.Adresar/GetAdresar
|
||||
❯ grpcurl -plaintext -d '{"id": 1}' localhost:50051 multieko2.adresar.Adresar/GetAdresar
|
||||
ERROR:
|
||||
Code: NotFound
|
||||
Message: no rows returned by a query that expected to return at least one row
|
||||
|
||||
@@ -30,13 +30,16 @@ pub async fn get_adresar(
|
||||
skladu,
|
||||
fax
|
||||
FROM adresar
|
||||
WHERE id = $1
|
||||
WHERE id = $1 AND deleted = false
|
||||
"#,
|
||||
request.id
|
||||
)
|
||||
.fetch_one(db_pool)
|
||||
.await
|
||||
.map_err(|e| Status::not_found(e.to_string()))?;
|
||||
.map_err(|e| match e {
|
||||
sqlx::Error::RowNotFound => Status::not_found("Record not found"),
|
||||
_ => Status::internal(format!("Database error: {}", e)),
|
||||
})?;
|
||||
|
||||
Ok(AdresarResponse {
|
||||
id: adresar.id,
|
||||
|
||||
Reference in New Issue
Block a user