diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-08-22 15:57:19 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-08-22 15:57:19 +0200 |
commit | af957a67eb34430d5788bf1d2cb8e1aa1e46f3ff (patch) | |
tree | 6758764e1008e2a3fc01c166f4618b137ac975d2 /pkg/config/yaml_test.go | |
parent | 1e57a00c41035b7c3a1c4c5f230281b7461d90a5 (diff) | |
download | feed2imap-go-af957a67eb34430d5788bf1d2cb8e1aa1e46f3ff.tar.gz feed2imap-go-af957a67eb34430d5788bf1d2cb8e1aa1e46f3ff.tar.bz2 feed2imap-go-af957a67eb34430d5788bf1d2cb8e1aa1e46f3ff.zip |
#26: Introduce new option `auto-target`
Diffstat (limited to 'pkg/config/yaml_test.go')
-rw-r--r-- | pkg/config/yaml_test.go | 41 |
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)}, |