forked from go-vela/worker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.go
More file actions
35 lines (25 loc) · 899 Bytes
/
server.go
File metadata and controls
35 lines (25 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2022 Target Brands, Inc. All rights reserved.
//
// Use of this source code is governed by the LICENSE file in this repository.
package worker
import (
"net/http"
"github.com/gin-gonic/gin"
)
// FakeHandler returns an http.Handler that is capable of handling
// Vela API requests and returning mock responses.
func FakeHandler() http.Handler {
gin.SetMode(gin.TestMode)
e := gin.New()
// mock endpoints for executor calls
e.GET("/api/v1/executors", getExecutors)
e.GET("/api/v1/executors/:executor", getExecutor)
// mock endpoints for build calls
e.GET("/api/v1/executors/:executor/build", getBuild)
e.DELETE("/api/v1/executors/:executor/build/cancel", cancelBuild)
// mock endpoints for pipeline calls
e.GET("/api/v1/executors/:executor/pipeline", getPipeline)
// mock endpoints for repo calls
e.GET("/api/v1/executors/:executor/repo", getRepo)
return e
}