Skip to content

Commit

Permalink
remove emoji.Dl
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Mar 17, 2023
1 parent 7809922 commit 5776536
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
23 changes: 8 additions & 15 deletions internal/app/emoji/emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ func Download(ctx context.Context, cfg config.Params, prov auth.Provider) error
return err
}
defer sess.Close()
return Dl(ctx, sess, cfg.Output.Base, cfg.Emoji.FailOnError)

fsa, err := fsadapter.New(cfg.Output.Base)
if err != nil {
return fmt.Errorf("unable to initialise adapter for %s: %w", cfg.Output.Base, err)
}
defer fsa.Close()

return DlFS(ctx, sess, fsa, cfg.Emoji.FailOnError)
}

//go:generate mockgen -source emoji.go -destination emoji_mock_test.go -package emoji
Expand All @@ -74,20 +81,6 @@ func DlFS(ctx context.Context, sess emojidumper, fsa fsadapter.FS, ignoreErrors
return fetch(ctx, fsa, emojis, true)
}

// Dl downloads all emojis from the workspace and saves them to the base
// directory or file.
//
// Deprecated: use DlFS instead.
func Dl(ctx context.Context, sess emojidumper, base string, ignoreErrors bool) error {
fsa, err := fsadapter.New(base)
if err != nil {
return fmt.Errorf("unable to initialise adapter for %s: %w", base, err)
}
defer fsa.Close()

return DlFS(ctx, sess, fsa, ignoreErrors)
}

// fetch downloads the emojis and saves them to the fsa. It spawns numWorker
// goroutines for getting the files. It will call fetchFn for each emoji.
func fetch(ctx context.Context, fsa fsadapter.FS, emojis map[string]string, failFast bool) error {
Expand Down
6 changes: 5 additions & 1 deletion internal/app/emoji/emoji_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@ func Test_download(t *testing.T) {
setGlobalFetchFn(tt.fetchFn)
sess := NewMockemojidumper(gomock.NewController(t))
tt.expect(sess)
if err := Dl(tt.args.ctx, sess, tt.args.output, tt.args.failFast); (err != nil) != tt.wantErr {
fs, err := fsadapter.New(tt.args.output)
if err != nil {
t.Fatal(err)
}
if err := DlFS(tt.args.ctx, sess, fs, tt.args.failFast); (err != nil) != tt.wantErr {
t.Errorf("download() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down

0 comments on commit 5776536

Please sign in to comment.