This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / appview / config / config_test.go
1.2 kB 49 lines
1package config 2 3import ( 4 "context" 5 "testing" 6 7 "tangled.org/core/consts" 8) 9 10func TestLoadConfig_DefaultKnotFallsBackToConst(t *testing.T) { 11 t.Setenv("TANGLED_KNOT_DEFAULT", "") 12 13 cfg, err := LoadConfig(context.Background()) 14 if err != nil { 15 t.Fatalf("LoadConfig: %v", err) 16 } 17 if cfg.Knot.Default != consts.DefaultKnot { 18 t.Fatalf("unset TANGLED_KNOT_DEFAULT = %q, want fallback %q", cfg.Knot.Default, consts.DefaultKnot) 19 } 20} 21 22func TestLoadConfig_DefaultKnotHonorsOverride(t *testing.T) { 23 t.Setenv("TANGLED_KNOT_DEFAULT", "kt.tngl.oyster.cafe") 24 25 cfg, err := LoadConfig(context.Background()) 26 if err != nil { 27 t.Fatalf("LoadConfig: %v", err) 28 } 29 if cfg.Knot.Default != "kt.tngl.oyster.cafe" { 30 t.Fatalf("TANGLED_KNOT_DEFAULT override = %q, want kt.tngl.oyster.cafe", cfg.Knot.Default) 31 } 32} 33 34func TestHostname_StripsPort(t *testing.T) { 35 cases := map[string]string{ 36 "127.0.0.1:3000": "127.0.0.1", 37 "localhost:3000": "localhost", 38 "tangled.org": "tangled.org", 39 "[::1]:3000": "::1", 40 } 41 for host, want := range cases { 42 t.Run(host, func(t *testing.T) { 43 c := &CoreConfig{AppviewHost: host} 44 if got := c.Hostname(); got != want { 45 t.Fatalf("Hostname() with AppviewHost=%q = %q, want %q", host, got, want) 46 } 47 }) 48 } 49}