-
Notifications
You must be signed in to change notification settings - Fork 0
/
fs-write-file_test.go
73 lines (63 loc) · 1.71 KB
/
fs-write-file_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
package nef_test
import (
. "github.com/onsi/ginkgo/v2" //nolint:revive // ok
. "github.com/onsi/gomega" //nolint:revive // ok
nef "github.com/snivilised/nefilim"
lab "github.com/snivilised/nefilim/internal/laboratory"
"github.com/snivilised/nefilim/test/luna"
)
var _ = Describe("op: write-file", Ordered, func() {
var root string
BeforeAll(func() {
root = luna.Repo("test")
})
Context("fs: WriteFileFS", func() {
BeforeEach(func() {
scratch(root)
})
Context("overwrite", func() {
var fS nef.WriteFileFS
BeforeEach(func() {
fS = nef.NewWriteFileFS(nef.Rel{
Root: root,
Overwrite: true,
})
Expect(fS.IsRelative()).To(BeTrue())
})
Context("op: WriteFile", func() {
When("given: file does not already exist", func() {
It("🧪 should: write successfully", func() {
Expect(require(root, lab.Static.FS.Scratch)).To(Succeed())
name := lab.Static.FS.Write.Destination
Expect(fS.WriteFile(
name, lab.Static.FS.Write.Content, lab.Perms.File.Perm(),
)).To(Succeed())
Expect(luna.AsFile(name)).To(luna.ExistInFS(fS))
})
})
})
})
Context("tentative", func() {
var fS nef.WriteFileFS
BeforeEach(func() {
fS = nef.NewWriteFileFS(nef.Rel{
Root: root,
Overwrite: false,
})
})
Context("op: WriteFile", func() {
When("given: file does not already exist", func() {
It("🧪 should: write successfully", func() {
file := lab.Static.FS.Write.Destination
Expect(require(
root, lab.Static.FS.Scratch, file,
)).To(Succeed())
Expect(fS.WriteFile(
file, lab.Static.FS.Write.Content, lab.Perms.File.Perm(),
)).To(Succeed())
})
})
})
})
})
})