...
1 package matchers_test
2
3 import (
4 "os"
5
6 . "github.com/onsi/ginkgo/v2"
7 . "github.com/onsi/gomega"
8 "github.com/onsi/gomega/internal/gutil"
9 . "github.com/onsi/gomega/matchers"
10 )
11
12 var _ = Describe("BeADirectoryMatcher", func() {
13 When("passed a string", func() {
14 It("should do the right thing", func() {
15 Expect("/dne/test").ShouldNot(BeADirectory())
16
17 tmpFile, err := os.CreateTemp("", "gomega-test-tempfile")
18 Expect(err).ShouldNot(HaveOccurred())
19 defer os.Remove(tmpFile.Name())
20 Expect(tmpFile.Name()).ShouldNot(BeADirectory())
21
22 tmpDir, err := gutil.MkdirTemp("", "gomega-test-tempdir")
23 Expect(err).ShouldNot(HaveOccurred())
24 defer os.Remove(tmpDir)
25 Expect(tmpDir).Should(BeADirectory())
26 })
27 })
28
29 When("passed something else", func() {
30 It("should error", func() {
31 success, err := (&BeADirectoryMatcher{}).Match(nil)
32 Expect(success).Should(BeFalse())
33 Expect(err).Should(HaveOccurred())
34
35 success, err = (&BeADirectoryMatcher{}).Match(true)
36 Expect(success).Should(BeFalse())
37 Expect(err).Should(HaveOccurred())
38 })
39 })
40 })
41
View as plain text