Skip to content

Commit

Permalink
fix(proxy): add transparent with trash path finder unit tests (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Feb 16, 2024
1 parent ae10b53 commit b6983af
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/app/proxy/common/filing-defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type (
Profile string
RunStep RunStepInfo
Cuddle bool
Output string
Trash string
}

PathFinder interface {
Expand Down
85 changes: 84 additions & 1 deletion src/app/proxy/filing/path-finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ var _ = Describe("PathFinder", Ordered, func() {
Profile: entry.profile,
Scheme: entry.scheme,
Cuddle: entry.cuddle,
Output: entry.output,
Trash: entry.trash,
}

var (
Expand Down Expand Up @@ -359,7 +361,88 @@ var _ = Describe("PathFinder", Ordered, func() {
}),

//
// NON-TRANSPARENT
// TRANSPARENT --trash SPECIFIED
//
Entry(nil, &pfTE{
given: "🌀 TRANSFER: transparent/profile/trash",
should: "redirect input to supplemented folder // filename not modified",
reasons: reasons{
folder: "transparency, result should take place of input in same folder",
file: "file should be moved out of the way and not cuddled",
},
profile: "blur",
trash: filepath.Join("foo", "sessions", "scan01", "rubbish"),
supplements: supplements{
folder: filepath.Join("$TRASH$", "blur"),
},
actionTransfer: true,
assert: func(folder, file string, pi *common.PathInfo, statics *common.StaticInfo, entry *pfTE) {
Expect(folder).To(Equal(filepath.Join(entry.trash, entry.supplements.folder)), because(entry.reasons.folder, folder))
Expect(file).To(Equal(pi.Item.Extension.Name), because(entry.reasons.file))
},
}),

Entry(nil, &pfTE{
given: "🎁 RESULT: transparent/profile/trash",
should: "not modify folder // not modify filename",
reasons: reasons{
folder: "transparency, result should take place of input",
file: "file should be moved out of the",
},
profile: "blur",
trash: filepath.Join("foo", "sessions", "scan01", "rubbish"),
assert: func(folder, file string, pi *common.PathInfo, statics *common.StaticInfo, entry *pfTE) {
Expect(folder).To(Equal(pi.Origin), because(entry.reasons.folder))
Expect(file).To(Equal(pi.Item.Extension.Name), because(entry.reasons.file))
},
}),

// === TRANSPARENT / SCHEME (non-cuddle) [BLUE]

Entry(nil, &pfTE{
given: "🌀 TRANSFER: transparent/profile/trash",
should: "redirect input to supplemented folder // filename not modified",
reasons: reasons{
folder: "transparency, result should take place of input in same folder",
file: "file should be moved out of the way",
},
scheme: "blur-sf",
profile: "blur",
trash: filepath.Join("foo", "sessions", "scan01", "rubbish"),
supplements: supplements{
folder: filepath.Join("rubbish", "$TRASH$", "blur-sf", "blur"),
},
actionTransfer: true,
assert: func(folder, file string, pi *common.PathInfo, statics *common.StaticInfo, entry *pfTE) {
Expect(folder).To(Equal(filepath.Join(pi.Origin, entry.supplements.folder)), because(entry.reasons.folder))
Expect(file).To(Equal(pi.Item.Extension.Name), because(entry.reasons.file))
},
}),

// ...

Entry(nil, &pfTE{
given: "🌀 TRANSFER: transparent/profile/trash",
should: "redirect input to supplemented folder // filename not modified",
reasons: reasons{
folder: "transparency, result should take place of input in same folder",
file: "file should be moved out of the way",
},
scheme: "blur-sf",
profile: "sf",
trash: filepath.Join("foo", "sessions", "scan01", "rubbish"),
supplements: supplements{
folder: filepath.Join("rubbish", "$TRASH$", "blur-sf", "sf"),
},
actionTransfer: true,
assert: func(folder, file string, pi *common.PathInfo, statics *common.StaticInfo, entry *pfTE) {
Expect(folder).To(Equal(filepath.Join(pi.Origin, entry.supplements.folder)), because(entry.reasons.folder))
Expect(file).To(Equal(pi.Item.Extension.Name), because(entry.reasons.file))
},
}),

//
// NON-TRANSPARENT --output SPECIFIED
//
)
})
4 changes: 4 additions & 0 deletions src/app/proxy/orc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func (c *Controller) OnNewShrinkItem(item *nav.TraverseItem) error {
Profile: c.session.Inputs.Root.ProfileFam.Native.Profile,
Origin: item.Extension.Parent,
Cuddle: c.session.Inputs.ParamSet.Native.Cuddle,
Output: c.session.Inputs.ParamSet.Native.OutputPath,
Trash: c.session.Inputs.ParamSet.Native.TrashPath,
}

var sequence common.Sequence
Expand Down Expand Up @@ -153,6 +155,8 @@ func (c *Controller) Run(item *nav.TraverseItem, sequence common.Sequence) error
Origin: item.Parent.Path,
Scheme: c.session.FileManager.Finder().Scheme(),
Cuddle: c.session.Inputs.ParamSet.Native.Cuddle,
Output: c.session.Inputs.ParamSet.Native.OutputPath,
Trash: c.session.Inputs.ParamSet.Native.TrashPath,
}

// TODO: need to decide a proper policy for cleaning up
Expand Down

0 comments on commit b6983af

Please sign in to comment.