aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/yaml_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/config/yaml_test.go')
-rw-r--r--pkg/config/yaml_test.go41
1 files changed, 34 insertions, 7 deletions
diff --git a/pkg/config/yaml_test.go b/pkg/config/yaml_test.go
index fdc5e80..09f721d 100644
--- a/pkg/config/yaml_test.go
+++ b/pkg/config/yaml_test.go
@@ -61,11 +61,12 @@ func TestBuildOptions(tst *testing.T) {
func TestBuildFeeds(tst *testing.T) {
tests := []struct {
- name string
- wantErr bool
- target string
- feeds []configGroupFeed
- result Feeds
+ name string
+ wantErr bool
+ target string
+ feeds []configGroupFeed
+ result Feeds
+ noAutoTarget bool
}{
{name: "Empty input", wantErr: false, target: "", feeds: nil, result: Feeds{}},
{name: "Empty Feed", wantErr: true, target: "",
@@ -93,12 +94,24 @@ func TestBuildFeeds(tst *testing.T) {
},
result: Feeds{"muh": &Feed{Name: "muh", Target: t("moep.foo")}},
},
+ {name: "Simple With Target and NoAutoTarget", wantErr: false, target: "moep", noAutoTarget: true,
+ feeds: []configGroupFeed{
+ {Target: n("foo"), Feed: feed{Name: "muh"}},
+ },
+ result: Feeds{"muh": &Feed{Name: "muh", Target: t("moep.foo")}},
+ },
{name: "Simple Without Target", wantErr: false, target: "moep",
feeds: []configGroupFeed{
{Feed: feed{Name: "muh"}},
},
result: Feeds{"muh": &Feed{Name: "muh", Target: t("moep.muh")}},
},
+ {name: "Simple Without Target and NoAutoTarget", wantErr: false, target: "moep", noAutoTarget: true,
+ feeds: []configGroupFeed{
+ {Feed: feed{Name: "muh"}},
+ },
+ result: Feeds{"muh": &Feed{Name: "muh", Target: t("moep")}},
+ },
{name: "Simple With Nil Target", wantErr: false, target: "moep",
feeds: []configGroupFeed{
{Target: yaml.Node{Tag: "!!null"}, Feed: feed{Name: "muh"}},
@@ -141,6 +154,20 @@ func TestBuildFeeds(tst *testing.T) {
"F3": &Feed{Name: "F3", Target: t("G1.F3")},
},
},
+ {name: "Simple Group, NoAutoTarget", wantErr: false, target: "IN", noAutoTarget: true,
+ feeds: []configGroupFeed{
+ {Group: group{Group: "G1", Feeds: []configGroupFeed{
+ {Target: n("bar"), Feed: feed{Name: "F1"}},
+ {Target: n(""), Feed: feed{Name: "F2"}},
+ {Feed: feed{Name: "F3"}},
+ }}},
+ },
+ result: Feeds{
+ "F1": &Feed{Name: "F1", Target: t("IN.bar")},
+ "F2": &Feed{Name: "F2", Target: t("IN")},
+ "F3": &Feed{Name: "F3", Target: t("IN")},
+ },
+ },
{name: "Nested Groups", wantErr: false, target: "",
feeds: []configGroupFeed{
{Group: group{Group: "G1", Feeds: []configGroupFeed{
@@ -165,7 +192,7 @@ func TestBuildFeeds(tst *testing.T) {
tst.Run(tt.name, func(tst *testing.T) {
var feeds = Feeds{}
var opts = Options{}
- err := buildFeeds(tt.feeds, t(tt.target), feeds, &opts)
+ err := buildFeeds(tt.feeds, t(tt.target), feeds, &opts, !tt.noAutoTarget)
if (err != nil) != tt.wantErr {
tst.Errorf("buildFeeds() error = %v, wantErr %v", err, tt.wantErr)
return
@@ -248,7 +275,7 @@ feeds:
Target: n("bar"),
Feed: feed{
Name: "Foo",
- Exec: []string{"whatever", "-i", "http://foo.bar"},
+ Exec: []string{"whatever", "-i", "http://foo.bar"},
},
Options: Map{"include-images": true, "unknown-option": "foo"},
}}, nil)},
of go-messageRené 'Necoro' Neumann3-10/+5 2020-04-21Update README.mdRené 'Necoro' Neumann1-0/+2 2020-04-21Improved HTML creationRené 'Necoro' Neumann4-3/+22 2020-04-21Upload mails to imapRené 'Necoro' Neumann3-35/+80 2020-04-21Move HTML template to stringRené 'Necoro' Neumann3-12/+13 2020-04-21HTML Template part of the mailRené 'Necoro' Neumann7-18/+199 2020-04-20Fixes and validationRené 'Necoro' Neumann6-28/+25 2020-04-20Fix vettingRené 'Necoro' Neumann1-1/+1 2020-04-20Started with mail creationRené 'Necoro' Neumann4-3/+126 2020-04-20FeeditemsRené 'Necoro' Neumann2-2/+14 2020-04-20GlobalOptionsRené 'Necoro' Neumann3-25/+79 2020-04-19RestructureRené 'Necoro' Neumann6-152/+177 2020-04-19Rename package 'parse' to 'feed'René 'Necoro' Neumann2-3/+3 2020-04-19SELECT is not necessary for most operations -- skip itRené 'Necoro' Neumann2-12/+1 2020-04-19Store path as array -- the delimiter is not always '.'René 'Necoro' Neumann3-36/+44 2020-04-19Split client part to client.goRené 'Necoro' Neumann2-125/+137 2020-04-19IMAP: Create foldersRené 'Necoro' Neumann1-4/+38 2020-04-19Improved IMAPRené 'Necoro' Neumann1-3/+88 2020-04-19Started IMAP connectionRené 'Necoro' Neumann4-0/+152 2020-04-19Use our own logger for debug for convenience sakeRené 'Necoro' Neumann1-2/+3 2020-04-19Fix debug logging m(René 'Necoro' Neumann1-2/+2 2020-04-19Rename util.go to log.go. Add verbose modeRené 'Necoro' Neumann4-24/+54 2020-04-19Clean go.modRené 'Necoro' Neumann2-3/+0 2020-04-19Do not print the parsedCfg anymoreRené 'Necoro' Neumann1-1/+1 2020-04-19Increase go-version to 1.14René 'Necoro' Neumann1-2/+2 2020-04-19CI: go vetRené 'Necoro' Neumann1-0/+3 2020-04-19Fetching and parsing the feedsRené 'Necoro' Neumann5-4/+113 2020-04-19Ignore all config*.ymlRené 'Necoro' Neumann1-1/+1