diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-06-02 23:05:58 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-06-02 23:10:40 +0200 |
commit | ee1d8b157e1f207ab181cf81ee7ab8f7c39fbeab (patch) | |
tree | a67ab397e71555c1d048199e32319d119c5c1817 /pkg/config/yaml_test.go | |
parent | 54d3ea0e7bce0a97db63c9cfa7b54794743b42a8 (diff) | |
download | feed2imap-go-ee1d8b157e1f207ab181cf81ee7ab8f7c39fbeab.tar.gz feed2imap-go-ee1d8b157e1f207ab181cf81ee7ab8f7c39fbeab.tar.bz2 feed2imap-go-ee1d8b157e1f207ab181cf81ee7ab8f7c39fbeab.zip |
More tests
Diffstat (limited to 'pkg/config/yaml_test.go')
-rw-r--r-- | pkg/config/yaml_test.go | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/pkg/config/yaml_test.go b/pkg/config/yaml_test.go index b4d5c9c..e649175 100644 --- a/pkg/config/yaml_test.go +++ b/pkg/config/yaml_test.go @@ -20,6 +20,8 @@ func n(s string) (n yaml.Node) { return } +var null = yaml.Node{Tag: nullTag} + func TestBuildOptions(tst *testing.T) { tests := []struct { name string @@ -120,7 +122,7 @@ func TestBuildFeeds(tst *testing.T) { }, {name: "Simple With Nil Target", wantErr: false, target: "moep", feeds: []configGroupFeed{ - {Target: yaml.Node{Tag: "!!null"}, Feed: feed{Name: "muh"}}, + {Target: null, Feed: feed{Name: "muh"}}, }, result: Feeds{"muh": &Feed{Name: "muh", Target: t("moep")}}, }, @@ -345,6 +347,8 @@ feeds: - name: F1 url: google.de - name: F2 + - name: F3 + target: - group: G3 `, wantErr: false, @@ -363,6 +367,7 @@ feeds: }}, }, {Feed: feed{Name: "F2"}}, + {Feed: feed{Name: "F3"}, Target: null}, {Group: group{Group: "G3"}}, }}, }, @@ -392,3 +397,53 @@ feeds: }) } } + +func TestCompleteFeed(tst *testing.T) { + inp := ` +feeds: + - name: Foo + url: whatever + - group: G1 + target: target + feeds: + - group: G2 + target: "" + feeds: + - name: F1 + url: google.de + - name: F2 + - name: F3 + target: + - name: F4 + target: "G4" + - name: F5 + target: ~ + - name: F6 + target: "" + - group: G3 + - group: G4 + feeds: + - name: F7 +` + res := Feeds{ + "Foo": &Feed{Name: "Foo", Target: t("Foo"), Url: "whatever"}, + "F1": &Feed{Name: "F1", Target: t("target.F1"), Url: "google.de"}, + "F2": &Feed{Name: "F2", Target: t("target.F2")}, + "F3": &Feed{Name: "F3", Target: t("target")}, + "F4": &Feed{Name: "F4", Target: t("target.G4")}, + "F5": &Feed{Name: "F5", Target: t("target")}, + "F6": &Feed{Name: "F6", Target: t("target")}, + "F7": &Feed{Name: "F7", Target: t("target.G4.F7")}, + } + + c := WithDefault() + c.FeedOptions = Options{} + + if err := c.parse(strings.NewReader(inp)); err != nil { + tst.Error(err) + } else { + if diff := cmp.Diff(res, c.Feeds); diff != "" { + tst.Error(diff) + } + } +} |