verify successful database interactions with test endpoint
This commit is contained in:
parent
c1930d6821
commit
51a34008f1
5 changed files with 38 additions and 13 deletions
internal/api
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"vegan-barcode/internal/database"
|
||||
"vegan-barcode/internal/utils"
|
||||
|
@ -46,6 +47,12 @@ func BindRoutes() {
|
|||
func (s *ApiService) runTest(c *gin.Context) {
|
||||
queryParam := c.Param("id")
|
||||
log.Debug("Test was successful.")
|
||||
|
||||
err := s.db.Insert(c, database.ProductsTable, &database.Product{System: "upc", Barcode: "fubar", Created_at: time.Now()})
|
||||
if err != nil {
|
||||
// TODO: Figure out correct status code.
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to insert item to product table", "error": err.Error()})
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Hello World!", "query_param": queryParam})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue