Skip to content

Commit

Permalink
Fixed the test case
Browse files Browse the repository at this point in the history
  • Loading branch information
shambhand committed Sep 13, 2024
1 parent cb619af commit 6419f8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -25,5 +25,6 @@ func GetAlbums(c *gin.Context) {

func SetUpRouter() *gin.Engine {
router := gin.Default()
router.GET("/albums", GetAlbums)
return router
}
5 changes: 1 addition & 4 deletions src/main.go
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 1 addition & 1 deletion src/test/get_albums_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6419f8f

Please sign in to comment.