This repository has been archived by the owner on Feb 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
out_test.go
85 lines (68 loc) · 1.63 KB
/
out_test.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package resource_test
import (
"bytes"
"encoding/json"
"io/ioutil"
"os"
"os/exec"
resource "github.com/cappyzawa/romver-resource"
"github.com/cappyzawa/romver-resource/driver"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Out", func() {
var srcDir string
var req struct {
Source resource.Source
Params resource.OutParams
}
var res struct {
Version resource.Version
Metadata resource.Metadata
}
BeforeEach(func() {
var err error
srcDir, err = ioutil.TempDir("", "romver-resource-out-dir")
Expect(err).NotTo(HaveOccurred())
req.Source = resource.Source{}
req.Params = resource.OutParams{}
res.Version = resource.Version{}
res.Metadata = resource.Metadata{}
})
AfterEach(func() {
Expect(os.RemoveAll(srcDir)).To(Succeed())
})
JustBeforeEach(func() {
cmd := exec.Command(bins.Out, srcDir)
payload, err := json.Marshal(req)
Expect(err).ToNot(HaveOccurred())
outBuf := new(bytes.Buffer)
cmd.Stdin = bytes.NewBuffer(payload)
cmd.Stdout = outBuf
cmd.Stderr = GinkgoWriter
err = cmd.Run()
Expect(err).ToNot(HaveOccurred())
err = json.Unmarshal(outBuf.Bytes(), &res)
Expect(err).ToNot(HaveOccurred())
})
Context("bump based on git file", func() {
BeforeEach(func() {
req.Source = resource.Source{
Driver: "git",
InitialVersion: "0",
URI: githubURI,
Branch: githubBranch,
Username: githubUsername,
Password: githubPassword,
File: "version",
}
req.Params = resource.OutParams{
Bump: true,
}
})
It("works", func() {
_, err := driver.FromSource(req.Source)
Expect(err).NotTo(HaveOccurred())
})
})
})