aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/template/funcs_test.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2022-01-09 00:20:24 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2022-01-09 00:20:24 +0100
commitd480edb65af5d6e9d8906940cdd4093761c1b451 (patch)
tree186cf7e2aee6576d84fdb3df11e6a06bc80d6a52 /internal/feed/template/funcs_test.go
parent0d3a8c8bab2fad592e192169a83e286d0d2ab692 (diff)
downloadfeed2imap-go-d480edb65af5d6e9d8906940cdd4093761c1b451.tar.gz
feed2imap-go-d480edb65af5d6e9d8906940cdd4093761c1b451.tar.bz2
feed2imap-go-d480edb65af5d6e9d8906940cdd4093761c1b451.zip
template: Restructuring and adding tests.
Diffstat (limited to 'internal/feed/template/funcs_test.go')
-rw-r--r--internal/feed/template/funcs_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/internal/feed/template/funcs_test.go b/internal/feed/template/funcs_test.go
new file mode 100644
index 0000000..c75d27d
--- /dev/null
+++ b/internal/feed/template/funcs_test.go
@@ -0,0 +1,57 @@
+package template
+
+import (
+ "testing"
+
+ "github.com/google/go-cmp/cmp"
+)
+
+func TestByteCount(t *testing.T) {
+ tests := map[string]struct {
+ inp string
+ out string
+ }{
+ "Empty": {"", "0 B"},
+ "Byte": {"123", "123 B"},
+ "KByte": {"2048", "2.0 KB"},
+ "KByte slight": {"2049", "2.0 KB"},
+ "KByte round": {"2560", "2.5 KB"},
+ "MByte": {"2097152", "2.0 MB"},
+ }
+
+ for name, tt := range tests {
+ t.Run(name, func(tst *testing.T) {
+ out := byteCount(tt.inp)
+
+ if diff := cmp.Diff(tt.out, out); diff != "" {
+ tst.Error(diff)
+ }
+ })
+ }
+}
+
+func TestDict(t *testing.T) {
+ type i []interface{}
+ type o map[string]interface{}
+
+ tests := map[string]struct {
+ inp i
+ out o
+ }{
+ "Empty": {i{}, o{}},
+ "One": {i{"1"}, o{"1": ""}},
+ "Two": {i{"1", 1}, o{"1": 1}},
+ "Three": {i{"1", "2", "3"}, o{"1": "2", "3": ""}},
+ "Four": {i{"1", 2, "3", '4'}, o{"1": 2, "3": '4'}},
+ }
+
+ for name, tt := range tests {
+ t.Run(name, func(tst *testing.T) {
+ out := dict(tt.inp...)
+
+ if diff := cmp.Diff(tt.out, o(out)); diff != "" {
+ tst.Error(diff)
+ }
+ })
+ }
+}
4:38 +0000'>2008-01-18 r661@Devoty: necoro | 2008-01-18 14:16:59 +0100Necoro8-211/+293 First support for interactive emerges r662@Devoty: necoro | 2008-01-18 20:22:58 +0100 Now finished interactive emerges 2008-01-18 r655@Devoty: necoro | 2008-01-18 03:04:53 +0100Necoro1-1/+1 Small bugfix 2008-01-18 r651@Devoty: necoro | 2008-01-18 02:41:51 +0100Necoro3-393/+513 adjust changelog and translation 2008-01-18 r643@Devoty: necoro | 2008-01-16 18:55:49 +0100Necoro14-249/+525 Fixed small bug in PackageTable.cb_package_revert_clicked r646@Devoty: necoro | 2008-01-18 00:12:30 +0100 Make tabpositions being configurable by the user r647@Devoty: necoro | 2008-01-18 01:38:19 +0100 Renamed 'shm' to '_shm' to not hide the global one r648@Devoty: necoro | 2008-01-18 01:38:29 +0100 Renamed 'shm' to '_shm' to not hide the global one r649@Devoty: necoro | 2008-01-18 02:34:43 +0100 Added update queues; general UI improvement 2008-01-14 r634@Devoty: necoro | 2008-01-14 23:48:24 +0100Necoro3-1/+4 Removed the broken plugins until they get replaced 2008-01-14 r632@Devoty: necoro | 2008-01-14 23:44:52 +0100Necoro3-175/+181 small changes 2008-01-14(no commit message)Necoro10-758/+1014 2008-01-14 r621@Devoty: necoro | 2008-01-14 20:21:40 +0100Necoro2-21/+61 adjust changelog r622@Devoty: necoro | 2008-01-14 21:01:11 +0100 Some new views 2008-01-14 r618@Devoty: necoro | 2008-01-14 20:19:05 +0100Necoro2-35/+57 An ALL category 2008-01-14 r617@Devoty: necoro | 2008-01-14 19:12:59 +0100Necoro2-10/+10 Remove unnecessairy loads of the shm module 2008-01-14 r609@Devoty: necoro | 2008-01-14 17:04:38 +0100Necoro9-394/+477 Allowed '-' and '_' in key names. Also use group names instead of their number. r610@Devoty: necoro | 2008-01-14 17:05:42 +0100 Disabled saving of the queues r611@Devoty: necoro | 2008-01-14 17:08:53 +0100 Added the possibility to permanently en-/disable plugins r612@Devoty: necoro | 2008-01-14 17:14:09 +0100 adjust changelog and translations r613@Devoty: necoro | 2008-01-14 17:40:53 +0100 Dropdown should be localized too 2008-01-14 r605@Devoty: necoro | 2008-01-14 11:43:34 +0100Necoro2-26/+129 Updated shm module to version 1.1.4 2008-01-14 r603@Devoty: necoro | 2008-01-14 11:30:26 +0100Necoro4-26/+38 Improved 'update world'; really support new use defaults 2008-01-11 r598@Devoty: necoro | 2008-01-10 16:36:29 +0100Necoro4-10/+50 Handle the new useflag format correctly 2008-01-11 r597@Devoty: necoro | 2008-01-10 14:12:35 +0100Necoro1-3/+3 updated todo 2008-01-10 r595@Devoty: necoro | 2008-01-10 04:04:15 +0100Necoro1-52/+3 Re-Introduced etc-proposals 2008-01-09 r586@Devoty: necoro | 2008-01-09 14:54:18 +0100Necoro1-1/+1 Disabled catapult till it is really usable 2007-12-06 r577@Devoty: necoro | 2007-12-06 20:37:36 +0100Necoro1-1/+1 Fixed desktop file 2007-12-06 r572@Devoty: necoro | 2007-11-28 08:48:15 +0100Necoro1-0/+1 2007-11-27 r570@Devoty: necoro | 2007-11-27 02:08:21 +0100Necoro3-84/+108 Added scrollbars to update window