-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
39 lines (31 loc) · 1.02 KB
/
main_test.go
File metadata and controls
39 lines (31 loc) · 1.02 KB
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
package main_test
import (
"context"
"os"
"os/exec"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Main", func() {
It("should load a project at the current filepath", func(ctx context.Context) {
wd, err := os.Getwd()
Expect(err).NotTo(HaveOccurred())
cmd := exec.CommandContext(ctx, cliPath)
ses, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(ses.Out).Should(gbytes.Say("Project: "))
Eventually(ses.Out).Should(gbytes.Say(wd))
Eventually(ses).Should(gexec.Exit(0))
})
It("should change to the given directory", func(ctx context.Context) {
dir := GinkgoT().TempDir()
cmd := exec.CommandContext(ctx, cliPath, "-C", dir)
ses, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(ses.Out).Should(gbytes.Say("Project: "))
Eventually(ses.Out).Should(gbytes.Say(dir))
Eventually(ses).Should(gexec.Exit(0))
})
})