From 5776536a4767528f003fd097ddc963d9fb3baf23 Mon Sep 17 00:00:00 2001 From: Rustam Gilyazov <16064414+rusq@users.noreply.github.com> Date: Fri, 17 Mar 2023 21:14:01 +1000 Subject: [PATCH] remove emoji.Dl --- internal/app/emoji/emoji.go | 23 ++++++++--------------- internal/app/emoji/emoji_test.go | 6 +++++- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/internal/app/emoji/emoji.go b/internal/app/emoji/emoji.go index cc3a0b24..ada067b3 100644 --- a/internal/app/emoji/emoji.go +++ b/internal/app/emoji/emoji.go @@ -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 @@ -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 { diff --git a/internal/app/emoji/emoji_test.go b/internal/app/emoji/emoji_test.go index 5fe2d8d7..d7826cc1 100644 --- a/internal/app/emoji/emoji_test.go +++ b/internal/app/emoji/emoji_test.go @@ -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) } })