Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Jan 9, 2025
1 parent 3136da0 commit 85e3e14
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
1 change: 0 additions & 1 deletion cmd/slackdump/internal/ui/bubbles/filemgr/filemgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ func (m Model) shorten(dirpath string) string {
var pathrepfn = strings.NewReplacer(string(filepath.Separator), "/").Replace

func toFSpath(p string) string {
r
if runtime.GOOS != "windows" {
// already '/'
return p
Expand Down
27 changes: 23 additions & 4 deletions cmd/slackdump/internal/ui/bubbles/filemgr/filemgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,33 @@ func Test_toFSpath(t *testing.T) {
p string
}
tests := []struct {
name string
args args
want string
name string
windows bool
args args
want string
}{
// TODO: Add test cases.
{
name: "updates path on windows",
windows: true,
args: args{
p: "C:\\Program Files\\Microsoft Office 95",
},
want: "C:/Program Files/Microsoft Office 95",
},
{
name: "returns as is on non-windows",
windows: false,
args: args{
p: "/var/spool/mail/root",
},
want: "/var/spool/mail/root",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if (runtime.GOOS == "windows") != tt.windows {
t.Skip("skipping")
}
if got := toFSpath(tt.args.p); got != tt.want {
t.Errorf("toFSpath() = %v, want %v", got, tt.want)
}
Expand Down

0 comments on commit 85e3e14

Please sign in to comment.