generated from snivilised/astrolib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
adceafc
commit eb30766
Showing
21 changed files
with
483 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ | |
"ineffassign", | ||
"Innerworld", | ||
"jdef", | ||
"jdir", | ||
"jibberjabber", | ||
"jroot", | ||
"Kontroller", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
package resume_test | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/fortytw2/leaktest" | ||
. "github.com/onsi/ginkgo/v2" //nolint:revive // ok | ||
. "github.com/onsi/gomega" //nolint:revive // ok | ||
"github.com/snivilised/li18ngo" | ||
nef "github.com/snivilised/nefilim" | ||
"github.com/snivilised/nefilim/test/luna" | ||
tv "github.com/snivilised/traverse" | ||
"github.com/snivilised/traverse/core" | ||
"github.com/snivilised/traverse/enums" | ||
"github.com/snivilised/traverse/internal/enclave" | ||
lab "github.com/snivilised/traverse/internal/laboratory" | ||
"github.com/snivilised/traverse/internal/services" | ||
"github.com/snivilised/traverse/locale" | ||
"github.com/snivilised/traverse/pref" | ||
"github.com/snivilised/traverse/test/hydra" | ||
"github.com/snivilised/traverse/tfs" | ||
) | ||
|
||
type arrangementSave struct { | ||
name, jdir string | ||
rS tv.TraversalFS | ||
} | ||
|
||
func (s *arrangementSave) arrange() *saveAsserter { | ||
const home = "home/prodigy" | ||
|
||
calc := s.rS.Calc() | ||
mocks := &nef.ResolveMocks{ | ||
HomeFunc: func() (string, error) { | ||
return calc.Join(s.jdir, "marshal", home), nil | ||
}, | ||
} | ||
|
||
full, _ := mocks.HomeFunc() | ||
file, err := s.rS.Ensure(nef.PathAs{ | ||
Name: full, | ||
Default: s.name, | ||
Perm: lab.Perms.Dir, | ||
}) | ||
directory, _ := calc.Split(file) | ||
|
||
Expect(err).To(Succeed()) | ||
Expect(luna.AsDirectory(directory)).To(luna.ExistInFS(s.rS)) | ||
|
||
return &saveAsserter{} | ||
} | ||
|
||
type saveAsserter struct { | ||
expectedErr error | ||
} | ||
|
||
func (a *saveAsserter) assert(result core.TraverseResult, actual, expected error) { | ||
Expect(actual).To(MatchError(expected)) | ||
Expect(result).NotTo(BeNil()) | ||
} | ||
|
||
var _ = Describe("Save", Ordered, func() { | ||
var ( | ||
from, jdir string | ||
fS *luna.MemFS | ||
rS tv.TraversalFS | ||
) | ||
|
||
BeforeAll(func() { | ||
Expect(li18ngo.Use( | ||
func(o *li18ngo.UseOptions) { | ||
o.From.Sources = li18ngo.TranslationFiles{ | ||
locale.SourceID: li18ngo.TranslationSource{Name: "traverse"}, | ||
} | ||
}, | ||
)).To(Succeed()) | ||
from = lab.GetJSONPath() | ||
jdir = lab.GetJSONDir() | ||
}) | ||
|
||
BeforeEach(func() { | ||
services.Reset() | ||
fS = hydra.Nuxx(verbose, lab.Static.RetroWave) | ||
rS = tfs.New() | ||
}) | ||
|
||
When("given: panic", func() { | ||
Context("prime", func() { | ||
It("🧪 should: save", func(specCtx SpecContext) { | ||
defer leaktest.Check(GinkgoT())() | ||
|
||
ctx, cancel := context.WithCancel(specCtx) | ||
defer cancel() | ||
|
||
arranged := (&arrangementSave{ | ||
name: "prime.walk.out.something.json", | ||
jdir: jdir, | ||
rS: rS, | ||
}).arrange() | ||
|
||
result, err := tv.Walk().Configure().Extent(tv.Prime( | ||
&pref.Using{ | ||
Subscription: enums.SubscribeDirectories, | ||
Head: pref.Head{ | ||
Handler: lab.PanicAt(lab.Static.TeenageColor), | ||
GetForest: func(_ string) *core.Forest { | ||
return &core.Forest{ | ||
T: fS, | ||
R: rS, | ||
} | ||
}, | ||
}, | ||
Tree: lab.Static.RetroWave, | ||
}, | ||
tv.WithOnBegin(lab.Begin("🛡️")), | ||
tv.WithOnEnd(lab.End("🏁")), | ||
)).Navigate(ctx) | ||
|
||
arranged.assert(result, err, locale.ErrCorePanicOccurred) | ||
}) | ||
}) | ||
|
||
Context("resume", func() { | ||
It("🧪 should: save", func(specCtx SpecContext) { | ||
defer leaktest.Check(GinkgoT())() | ||
|
||
ctx, cancel := context.WithCancel(specCtx) | ||
defer cancel() | ||
|
||
arranged := (&arrangementSave{ | ||
name: "resume.walk.out.something.json", | ||
jdir: jdir, | ||
rS: rS, | ||
}).arrange() | ||
|
||
result, err := tv.Walk().Configure(enclave.Loader(func(active *core.ActiveState) { | ||
active.Tree = lab.Static.RetroWave | ||
active.TraverseDescription = core.FsDescription{ | ||
IsRelative: true, | ||
} | ||
active.CurrentPath = lab.Static.NorthernCouncil | ||
active.Subscription = enums.SubscribeUniversal | ||
})).Extent(tv.Resume( | ||
&pref.Relic{ | ||
Head: pref.Head{ | ||
Handler: lab.PanicAt(lab.Static.ElectricYouth), | ||
GetForest: func(_ string) *core.Forest { | ||
return &core.Forest{ | ||
T: fS, | ||
R: rS, | ||
} | ||
}, | ||
}, | ||
From: from, | ||
Strategy: enums.ResumeStrategyFastward, | ||
}, | ||
tv.WithOnBegin(lab.Begin("🛡️")), | ||
tv.WithOnEnd(lab.End("🏁")), | ||
)).Navigate(ctx) | ||
|
||
arranged.assert(result, err, locale.ErrCorePanicOccurred) | ||
}) | ||
}) | ||
|
||
// TODO: repeat for concurrent sync. | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package kernel | ||
|
||
import ( | ||
"errors" | ||
"io/fs" | ||
|
||
"github.com/snivilised/traverse/internal/persist" | ||
"github.com/snivilised/traverse/pref" | ||
) | ||
|
||
type author struct { | ||
o *pref.Options | ||
path string | ||
perm fs.FileMode | ||
} | ||
|
||
func (a *author) write(vapour inspection) error { | ||
if a.path == "" { | ||
return errors.New("temporary: write failed, path missing") | ||
} | ||
|
||
s := vapour.static() | ||
forest := s.mediator.resources.Forest | ||
active := vapour.active(s.tree, forest, | ||
s.mediator.periscope.Depth(), | ||
s.mediator.metrics, | ||
) | ||
|
||
request := &persist.MarshalRequest{ | ||
Active: active, | ||
O: a.o, | ||
Path: a.path, | ||
Perm: a.perm, | ||
FS: s.mediator.resources.Forest.R, | ||
} | ||
|
||
_, err := persist.Marshal(request) | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.