From ee572ad0b7d4be3f71939e2164ecd27184c1ba75 Mon Sep 17 00:00:00 2001 From: plastikfan Date: Mon, 4 Nov 2024 20:01:11 +0000 Subject: [PATCH] chore(deps): bump nefilim to v0.1.7 --- go.mod | 2 +- go.sum | 2 + src/generators/gola/mem-fs_test.go | 141 ------------------ src/generators/gola/signature_test.go | 5 +- .../gola/source-code-generator_test.go | 4 +- 5 files changed, 9 insertions(+), 145 deletions(-) delete mode 100644 src/generators/gola/mem-fs_test.go diff --git a/go.mod b/go.mod index d0b8e39..00cbf36 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/onsi/ginkgo/v2 v2.21.0 github.com/onsi/gomega v1.35.1 github.com/snivilised/li18ngo v0.1.7 - github.com/snivilised/nefilim v0.1.4 + github.com/snivilised/nefilim v0.1.7 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 go.uber.org/mock v0.5.0 diff --git a/go.sum b/go.sum index 91840ed..3ad2840 100644 --- a/go.sum +++ b/go.sum @@ -53,6 +53,8 @@ github.com/snivilised/li18ngo v0.1.7 h1:XRYpmP7jSAxzRyg5WH0PViFb9ycWGFcDkQQqd2Gs github.com/snivilised/li18ngo v0.1.7/go.mod h1:NVOexqt/aIhnenNPQDqbJchLNte92io87j5o2l+HNqs= github.com/snivilised/nefilim v0.1.4 h1:bhiENDl/T6ZQO146eF8UnxtXLQenSzEyjwuTeWScImw= github.com/snivilised/nefilim v0.1.4/go.mod h1:+4/hKxgfvE8eNjLMJC+3ropEZSQuiR/NqfPtIuw7ZMw= +github.com/snivilised/nefilim v0.1.7 h1:T7ekCkLCrDVcTCeodgomX/sehNIRsGNN+aiv/u5Yn+E= +github.com/snivilised/nefilim v0.1.7/go.mod h1:+4/hKxgfvE8eNjLMJC+3ropEZSQuiR/NqfPtIuw7ZMw= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= diff --git a/src/generators/gola/mem-fs_test.go b/src/generators/gola/mem-fs_test.go deleted file mode 100644 index b1e6dbf..0000000 --- a/src/generators/gola/mem-fs_test.go +++ /dev/null @@ -1,141 +0,0 @@ -package gola_test - -import ( - "io/fs" - "os" - "strings" - "testing/fstest" - - "github.com/snivilised/cobrass/src/internal/lab" - "github.com/snivilised/cobrass/src/internal/third/lo" - nef "github.com/snivilised/nefilim" -) - -// nefilim should export this struct for us, so we dont have to re-implement -type TestMemFS struct { - fstest.MapFS -} - -func NewTestMemFS() *TestMemFS { - return &TestMemFS{ - MapFS: fstest.MapFS{}, - } -} - -func (f *TestMemFS) FileExists(name string) bool { - if mapFile, found := f.MapFS[name]; found && !mapFile.Mode.IsDir() { - return true - } - - return false -} - -func (f *TestMemFS) DirectoryExists(name string) bool { - if mapFile, found := f.MapFS[name]; found && mapFile.Mode.IsDir() { - return true - } - - return false -} - -func (f *TestMemFS) Create(name string) (*os.File, error) { - if _, err := f.Stat(name); err == nil { - return nil, fs.ErrExist - } - - file := &fstest.MapFile{ - Mode: lab.Perms.File, - } - - f.MapFS[name] = file - // TODO: this needs a resolution using a file interface - // rather than using os.File which is a struct not an - // interface - dummy := &os.File{} - - return dummy, nil -} - -func (f *TestMemFS) MakeDir(name string, perm os.FileMode) error { - if !fs.ValidPath(name) { - return nef.NewInvalidPathError("MakeDir", name) - } - - if _, found := f.MapFS[name]; !found { - f.MapFS[name] = &fstest.MapFile{ - Mode: perm | os.ModeDir, - } - } - - return nil -} - -func (f *TestMemFS) MakeDirAll(name string, perm os.FileMode) error { - if !fs.ValidPath(name) { - return nef.NewInvalidPathError("MakeDirAll", name) - } - - segments := strings.Split(name, "/") - - _ = lo.Reduce(segments, - func(acc []string, s string, _ int) []string { - acc = append(acc, s) - path := strings.Join(acc, "/") - - if _, found := f.MapFS[path]; !found { - f.MapFS[path] = &fstest.MapFile{ - Mode: perm | os.ModeDir, - } - } - - return acc - }, []string{}, - ) - - return nil -} - -func (f *TestMemFS) WriteFile(name string, data []byte, perm os.FileMode) error { - if _, err := f.Stat(name); err == nil { - return fs.ErrExist - } - - f.MapFS[name] = &fstest.MapFile{ - Data: data, - Mode: perm, - } - - return nil -} - -func (f *TestMemFS) Change(_, _ string) error { - panic("NOT-IMPL: TestMemFS.Change") -} - -func (f *TestMemFS) Copy(_, _ string) error { - panic("NOT-IMPL: TestMemFS.Copy") -} - -func (f *TestMemFS) CopyFS(_ string, _ fs.FS) error { - panic("NOT-IMPL: TestMemFS.CopyFS") -} - -func (f *TestMemFS) Ensure(_ nef.PathAs) (string, error) { - panic("NOT-IMPL: TestMemFS.Ensure") -} - -func (f *TestMemFS) Move(_, _ string) error { - panic("NOT-IMPL: TestMemFS.Move") -} - -func (f *TestMemFS) Remove(_ string) error { - panic("NOT-IMPL: TestMemFS.Remove") -} - -func (f *TestMemFS) RemoveAll(_ string) error { - panic("NOT-IMPL: TestMemFS.RemoveAll") -} - -func (f *TestMemFS) Rename(_, _ string) error { - panic("NOT-IMPL: TestMemFS.Rename") -} diff --git a/src/generators/gola/signature_test.go b/src/generators/gola/signature_test.go index 7b307b0..0ace0b1 100644 --- a/src/generators/gola/signature_test.go +++ b/src/generators/gola/signature_test.go @@ -11,6 +11,7 @@ import ( "github.com/snivilised/cobrass/src/generators/gola" "github.com/snivilised/cobrass/src/internal/lab" nef "github.com/snivilised/nefilim" + "github.com/snivilised/nefilim/test/luna" ) type setupFile struct { @@ -58,7 +59,7 @@ var _ = Describe("Signature", Ordered, func() { Context("and: Test mode", func() { Context("and: without write", func() { It("🧪 should: return hash result of newly generated content", func() { - fS := NewTestMemFS() + fS := luna.NewMemFS() templatesSubPath := "" outputPath = filepath.Join(repo, testPath) @@ -136,7 +137,7 @@ var _ = Describe("Signature", Ordered, func() { doWrite = true ) - fS := NewTestMemFS() + fS := luna.NewMemFS() templatesSubPath := "" outputPath = filepath.Join(repo, testPath) diff --git a/src/generators/gola/source-code-generator_test.go b/src/generators/gola/source-code-generator_test.go index 9cda34d..403ead3 100644 --- a/src/generators/gola/source-code-generator_test.go +++ b/src/generators/gola/source-code-generator_test.go @@ -8,6 +8,7 @@ import ( "github.com/snivilised/cobrass/src/generators/gola" nef "github.com/snivilised/nefilim" + "github.com/snivilised/nefilim/test/luna" ) var _ = Describe("SourceCodeGenerator", Ordered, func() { @@ -19,7 +20,8 @@ var _ = Describe("SourceCodeGenerator", Ordered, func() { BeforeAll(func() { repo = Repo("../..") testPath = filepath.Join("src", "generators", "gola", "out", "assistant") - fS = NewTestMemFS() + luna.NewMemFS() + fS = luna.NewMemFS() }) Context("AnyMissing", func() {