summaryrefslogtreecommitdiff
path: root/internal/queue
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-10-17 10:38:40 +0300
committerPaul Buetow <paul@buetow.org>2024-10-17 10:38:40 +0300
commit563ea5dbaaa77e59939812d6825d54cf829db8eb (patch)
tree1518d99868e86357f4ae81c0946f209adad4d8c1 /internal/queue
parenta66b2114ee9fb9078d6f3c12566d7178e0662903 (diff)
implement sizeLimit per platform
Diffstat (limited to 'internal/queue')
-rw-r--r--internal/queue/queue.go2
-rw-r--r--internal/queue/sharetags.go4
-rw-r--r--internal/queue/sharetags_test.go8
3 files changed, 8 insertions, 6 deletions
diff --git a/internal/queue/queue.go b/internal/queue/queue.go
index 73d5789..ddd3136 100644
--- a/internal/queue/queue.go
+++ b/internal/queue/queue.go
@@ -65,7 +65,7 @@ func queuePlatforms(args config.Args) error {
}
for filePath := range ch {
- for _, platform := range args.Platforms {
+ for platform := range args.Platforms {
if newShareTags(args, filePath).IsExcluded(platform) {
log.Println("Not queueing entry", filePath, "to platform", platform, "as it is excluded")
continue
diff --git a/internal/queue/sharetags.go b/internal/queue/sharetags.go
index 53d6306..b8088c0 100644
--- a/internal/queue/sharetags.go
+++ b/internal/queue/sharetags.go
@@ -32,7 +32,9 @@ func newShareTags(args config.Args, filePath string) shareTags {
if len(s.includes) == 0 && len(s.excludes) == 0 {
// If nothing found, include all of them
- s.includes = args.Platforms
+ for platform := range args.Platforms {
+ s.includes = append(s.includes, platform)
+ }
}
return s
diff --git a/internal/queue/sharetags_test.go b/internal/queue/sharetags_test.go
index b2dbeec..2a2a6aa 100644
--- a/internal/queue/sharetags_test.go
+++ b/internal/queue/sharetags_test.go
@@ -10,10 +10,10 @@ import (
func TestShareTagsPositive(t *testing.T) {
t.Parallel()
- args := config.Args{Platforms: []string{"mastodon", "linkedin"}}
+ args := config.Args{Platforms: map[string]int{"mastodon": 100, "linkedin": 100}}
testTable := map[string]shareTags{
"./foo/bar.without.tags.txt": {
- includes: args.Platforms, // No tags: default platforms
+ includes: []string{"mastodon", "linkedin"},
},
"./foo/bar.share:linkedin.txt": {
includes: []string{"linkedin"},
@@ -46,7 +46,7 @@ func TestShareTagsPositive(t *testing.T) {
func TestShareTagsNegative(t *testing.T) {
t.Parallel()
- args := config.Args{Platforms: []string{"mastodon", "linkedin"}}
+ args := config.Args{Platforms: map[string]int{"mastodon": 100, "linkedin": 100}}
testTable := map[string]shareTags{
"./foo/bar.without.tags.txt": {
includes: []string{"linkedin"},
@@ -101,7 +101,7 @@ func TestShareTagsIsIncluded(t *testing.T) {
}
}
}
- args := config.Args{Platforms: []string{"mastodon", "linkedin"}}
+ args := config.Args{Platforms: map[string]int{"mastodon": 100, "linkedin": 100}}
filePath := "foo/bar/baz.txt"
t.Run(filePath, func(t *testing.T) {