summaryrefslogtreecommitdiff
path: root/internal/entry
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-11-22 23:48:28 +0200
committerPaul Buetow <paul@buetow.org>2024-11-22 23:48:28 +0200
commitc095b7fb273eed04cae0d42cae2d534cf74cfd9e (patch)
tree7b12d51cae47a070622db6eb09539a31be8f0f69 /internal/entry
parentfaf7569ab307eff706e4ccf2ed92eec5c93f67eb (diff)
some stuff all around
Diffstat (limited to 'internal/entry')
-rw-r--r--internal/entry/entry.go7
-rw-r--r--internal/entry/sharetags.go6
-rw-r--r--internal/entry/sharetags_test.go13
3 files changed, 12 insertions, 14 deletions
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": {