From c095b7fb273eed04cae0d42cae2d534cf74cfd9e Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 22 Nov 2024 23:48:28 +0200 Subject: some stuff all around --- internal/entry/entry.go | 7 +++---- internal/entry/sharetags.go | 6 +++--- internal/entry/sharetags_test.go | 13 ++++++------- 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'internal/entry') diff --git a/internal/entry/entry.go b/internal/entry/entry.go index 25fb44a..d767410 100644 --- a/internal/entry/entry.go +++ b/internal/entry/entry.go @@ -11,7 +11,6 @@ import ( "codeberg.org/snonux/gos/internal/config" "codeberg.org/snonux/gos/internal/oi" - "codeberg.org/snonux/gos/internal/platforms" "codeberg.org/snonux/gos/internal/prompt" "codeberg.org/snonux/gos/internal/timestamp" ) @@ -155,10 +154,10 @@ func (en Entry) HasTag(tag string) bool { // Valid tags are: share:foo[,...] // whereas foo can be a supported plutform such as linkedin, mastodon, etc. // foo can also be prefixed with - to exclude it. See unit tests for examples. -func (en Entry) PlatformExcluded(args config.Args, platform platforms.Platform) (bool, error) { +func (en Entry) PlatformExcluded(args config.Args, platformStr string) (bool, error) { s, err := newShareTags(args, en.tags) - return slices.Contains(s.excludes, platform.String()) || - !slices.Contains(s.includes, platform.String()), err + return slices.Contains(s.excludes, platformStr) || + !slices.Contains(s.includes, platformStr), err } func (en Entry) Edit() error { diff --git a/internal/entry/sharetags.go b/internal/entry/sharetags.go index 666a3d4..21421ab 100644 --- a/internal/entry/sharetags.go +++ b/internal/entry/sharetags.go @@ -29,11 +29,11 @@ func newShareTags(args config.Args, tags map[string]struct{}) (shareTags, error) } if len(s.includes) == 0 { - for platform := range args.Platforms { - if slices.Contains(s.excludes, platform.String()) { + for platformStr := range args.Platforms { + if slices.Contains(s.excludes, platformStr) { continue } - s.includes = append(s.includes, platform.String()) + s.includes = append(s.includes, platformStr) } } diff --git a/internal/entry/sharetags_test.go b/internal/entry/sharetags_test.go index 7b1d742..73ba8db 100644 --- a/internal/entry/sharetags_test.go +++ b/internal/entry/sharetags_test.go @@ -6,13 +6,12 @@ import ( "testing" "codeberg.org/snonux/gos/internal/config" - "codeberg.org/snonux/gos/internal/platforms" ) func TestShareTagsPositive(t *testing.T) { - args := config.Args{Platforms: map[platforms.Platform]int{ - platforms.Platform("mastodon"): 100, - platforms.Platform("linkedin"): 100, + args := config.Args{Platforms: map[string]int{ + "mastodon": 100, + "linkedin": 100, }} testTable := map[string]shareTags{ "./foo/bar.without.tags.txt.20240101-010101.queued": { @@ -57,9 +56,9 @@ func TestShareTagsPositive(t *testing.T) { } } func TestShareTagsNegative(t *testing.T) { - args := config.Args{Platforms: map[platforms.Platform]int{ - platforms.Platform("mastodon"): 100, - platforms.Platform("linkedin"): 100, + args := config.Args{Platforms: map[string]int{ + string("mastodon"): 100, + string("linkedin"): 100, }} testTable := map[string]shareTags{ "./foo/bar.without.tags.txt.20240101-010101.queued": { -- cgit v1.2.3