diff --git a/src/app/app.go b/src/app/app.go index 0f46cc8..d086956 100644 --- a/src/app/app.go +++ b/src/app/app.go @@ -7,10 +7,10 @@ import ( ) type Album struct { - ID string `json: "Id"` - Title string `json: "title"` - Artist string `json: artist"` - Price float64 `json: "price"` + ID string `json:"id"` + Title string `json:"title"` + Artist string `json:"artist"` + Price float64 `json:"price"` } var albums = []Album{ @@ -25,5 +25,6 @@ func GetAlbums(c *gin.Context) { func SetUpRouter() *gin.Engine { router := gin.Default() + router.GET("/albums", GetAlbums) return router } diff --git a/src/main.go b/src/main.go index 111d3cd..1c986f6 100644 --- a/src/main.go +++ b/src/main.go @@ -1,11 +1,8 @@ package main -import "github.com/devops-journey/src/app" - +import "github.com/devops-journey/src/app" func main() { router := app.SetUpRouter() - router.GET("/albums", app.GetAlbums) - router.Run(":8000") } diff --git a/src/test/get_albums_test.go b/src/test/get_albums_test.go index 6d17d60..6e3fd49 100644 --- a/src/test/get_albums_test.go +++ b/src/test/get_albums_test.go @@ -25,7 +25,7 @@ func TestGetAlbums(t *testing.T) { {ID: "3", Title: "Sarah Vaughan and Clifford Brown", Artist: "Sarah Vaughan", Price: 39.99}, } - var actualAlbums []string + var actualAlbums []app.Album json.Unmarshal([]byte(response.Body.String()), &actualAlbums) assert.Equal(t, http.StatusOK, response.Code)