Skip to content

Commit

Permalink
ServeDevfileIndexV1 testing added.
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Valdron <[email protected]>
  • Loading branch information
michael-valdron committed Jul 29, 2022
1 parent 38b468a commit eb6d6f8
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions index/server/pkg/server/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,40 @@ func TestServeHealthCheck(t *testing.T) {

func TestServeDevfileIndexV1(t *testing.T) {
// TODO: Create testing data for ServeDevfileIndexV1 mock testing
tests := []struct {
name string
params gin.Params
wantCode int
}{
{
name: "Successful Response Test",
params: gin.Params{
gin.Param{Key: "name", Value: "nodejs"},
gin.Param{Key: "starterProjectName", Value: "nodejs-starter"},
},
wantCode: 200,
},
{
name: "Not Found Response Test",
params: gin.Params{
gin.Param{Key: "name", Value: "node"},
},
wantCode: 404,
},
}

gin.SetMode(gin.TestMode)
for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
gin.SetMode(gin.TestMode)

w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)

// TODO: Insert params
c.Params = test.params

server.ServeDevfileIndexV1(c)
server.ServeDevfileIndexV1(c)

// TODO: Insert checks
// TODO: Insert checks
})
}
}

0 comments on commit eb6d6f8

Please sign in to comment.