-
Notifications
You must be signed in to change notification settings - Fork 16
/
manifest.go
33 lines (26 loc) · 870 Bytes
/
manifest.go
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
package mockbosh
import (
"fmt"
"github.com/cloudfoundry-incubator/bosh-backup-and-restore/internal/cf-webmock/mockhttp"
. "github.com/onsi/gomega"
"gopkg.in/yaml.v2"
)
type manifestMock struct {
*mockhttp.MockHttp
}
func GetDeployment(deploymentName string) *manifestMock {
mock := &manifestMock{MockHttp: mockhttp.NewMockedHttpRequest("GET", fmt.Sprintf("/deployments/%s", deploymentName))}
return mock
}
func Manifest(deploymentName string) *manifestMock {
return GetDeployment(deploymentName)
}
func (t *manifestMock) RespondsWith(manifest []byte) *mockhttp.MockHttp {
data := map[string]string{"manifest": string(manifest)}
return t.RespondsWithJson(data)
}
func (t *manifestMock) RespondsWithManifest(manifest interface{}) *mockhttp.MockHttp {
data, err := yaml.Marshal(manifest)
Expect(err).NotTo(HaveOccurred())
return t.RespondsWith(data)
}