vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Move release channels to an authoritative channels.db
262e516e838cfc4b16b5d00fd98d5e4ef135aa85 · Keenan Nemetz · 19d ago · parent 24019cb3
Move release channels to an authoritative channels.db Channels are consumed from the public URL and are server-side publication state, so they no longer live on the vole branch or in the derived index. - forge/channel: authoritative SQLite store with schema, validation, and CRUD - config: data/channels.db, opened and closed with the instance - CLI: release channel set|list|clear over a new vole-channel SSH verb - server: maintain for set/clear, read for list, annotated-tag validation, audit channel.set/channel.clear, JSON list - web: channel page and tree read the store; release badges query it - remove the metadata-branch channel parser/validator, the index-derived channel table, and the hook path rules - backup, instance-data, and architecture docs include channels.db Refs: 01M7BPHANWMSW5HK2GT0PY74QZ
forge/channel/channel_test.go +140
| @@ -0,0 +1,140 @@ | |||
| 1 | package channel | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "path/filepath" | ||
| 5 | "strings" | ||
| 6 | "testing" | ||
| 7 | "time" | ||
| 8 | ) | ||
| 9 | |||
| 10 | func openTest(t *testing.T) *Store { | ||
| 11 | t.Helper() | ||
| 12 | s, err := Open(filepath.Join(t.TempDir(), "channels.db")) | ||
| 13 | if err != nil { | ||
| 14 | t.Fatal(err) | ||
| 15 | } | ||
| 16 | t.Cleanup(func() { s.Close() }) | ||
| 17 | return s | ||
| 18 | } | ||
| 19 | |||
| 20 | func TestValidName(t *testing.T) { | ||
| 21 | t.Parallel() | ||
| 22 | for _, ok := range []string{"stable", "latest", "beta", "lts-2026", "a"} { | ||
| 23 | if err := ValidName(ok); err != nil { | ||
| 24 | t.Errorf("ValidName(%q) = %v", ok, err) | ||
| 25 | } | ||
| 26 | } | ||
| 27 | for _, bad := range []string{"", "Stable", "-stable", "stable/", "stable.md", "a b", strings.Repeat("a", MaxNameLen+1), ".", ".."} { | ||
| 28 | if err := ValidName(bad); err == nil { | ||
| 29 | t.Errorf("ValidName(%q) = nil", bad) | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | func testChannel(name, tag string) Channel { | ||
| 35 | return Channel{ | ||
| 36 | Name: name, | ||
| 37 | Release: tag, | ||
| 38 | ReleaseObject: strings.Repeat("a", 40), | ||
| 39 | UpdatedBy: "keenan", | ||
| 40 | UpdatedAt: time.Date(2026, 11, 14, 12, 0, 0, 0, time.UTC), | ||
| 41 | Description: "Recommended.", | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | func TestSetGetListClear(t *testing.T) { | ||
| 46 | t.Parallel() | ||
| 47 | s := openTest(t) | ||
| 48 | ch := testChannel("stable", "v1.0.0") | ||
| 49 | if err := s.Set("repo1", ch); err != nil { | ||
| 50 | t.Fatal(err) | ||
| 51 | } | ||
| 52 | got, ok, err := s.Get("repo1", "stable") | ||
| 53 | if err != nil || !ok { | ||
| 54 | t.Fatalf("Get = %+v, %v, %v", got, ok, err) | ||
| 55 | } | ||
| 56 | if got.Release != ch.Release || got.ReleaseObject != ch.ReleaseObject || | ||
| 57 | got.UpdatedBy != ch.UpdatedBy || !got.UpdatedAt.Equal(ch.UpdatedAt) || | ||
| 58 | got.Description != ch.Description { | ||
| 59 | t.Fatalf("Get = %+v, want %+v", got, ch) | ||
| 60 | } | ||
| 61 | list, err := s.List("repo1") | ||
| 62 | if err != nil || len(list) != 1 || list[0].Name != "stable" { | ||
| 63 | t.Fatalf("List = %+v, %v", list, err) | ||
| 64 | } | ||
| 65 | if names, err := s.ForTag("repo1", "v1.0.0"); err != nil || len(names) != 1 { | ||
| 66 | t.Fatalf("ForTag = %v, %v", names, err) | ||
| 67 | } | ||
| 68 | |||
| 69 | // A move replaces the target and removes the old tag association. | ||
| 70 | ch.Release = "v2.0.0" | ||
| 71 | ch.ReleaseObject = strings.Repeat("b", 40) | ||
| 72 | ch.Description = "New stable." | ||
| 73 | if err := s.Set("repo1", ch); err != nil { | ||
| 74 | t.Fatal(err) | ||
| 75 | } | ||
| 76 | if names, _ := s.ForTag("repo1", "v1.0.0"); len(names) != 0 { | ||
| 77 | t.Fatalf("old tag still names channels: %v", names) | ||
| 78 | } | ||
| 79 | if list, _ := s.List("repo1"); len(list) != 1 || list[0].Description != "New stable." { | ||
| 80 | t.Fatalf("moved channel = %+v", list) | ||
| 81 | } | ||
| 82 | |||
| 83 | // Another repository cannot see it. | ||
| 84 | if _, ok, _ := s.Get("repo2", "stable"); ok { | ||
| 85 | t.Fatal("channel leaked across repositories") | ||
| 86 | } | ||
| 87 | if ok, err := s.Clear("repo1", "stable"); err != nil || !ok { | ||
| 88 | t.Fatalf("Clear = %v, %v", ok, err) | ||
| 89 | } | ||
| 90 | if ok, _ := s.Clear("repo1", "stable"); ok { | ||
| 91 | t.Fatal("clearing a missing channel reported a row") | ||
| 92 | } | ||
| 93 | if list, _ := s.List("repo1"); len(list) != 0 { | ||
| 94 | t.Fatalf("after clear = %+v", list) | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | func TestSetValidates(t *testing.T) { | ||
| 99 | t.Parallel() | ||
| 100 | s := openTest(t) | ||
| 101 | valid := testChannel("stable", "v1.0.0") | ||
| 102 | for name, mutate := range map[string]func(*Channel){ | ||
| 103 | "name": func(c *Channel) { c.Name = "Stable" }, | ||
| 104 | "tag": func(c *Channel) { c.Release = "" }, | ||
| 105 | "long tag": func(c *Channel) { c.Release = strings.Repeat("v", MaxTagLen+1) }, | ||
| 106 | "object": func(c *Channel) { c.ReleaseObject = "nope" }, | ||
| 107 | "updated by": func(c *Channel) { c.UpdatedBy = "" }, | ||
| 108 | "updated at": func(c *Channel) { c.UpdatedAt = time.Time{} }, | ||
| 109 | "description": func(c *Channel) { c.Description = strings.Repeat("x", MaxDescription+1) }, | ||
| 110 | } { | ||
| 111 | ch := valid | ||
| 112 | mutate(&ch) | ||
| 113 | if err := s.Set("repo1", ch); err == nil { | ||
| 114 | t.Errorf("%s: Set accepted the channel", name) | ||
| 115 | } | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | func TestOpenPersists(t *testing.T) { | ||
| 120 | t.Parallel() | ||
| 121 | path := filepath.Join(t.TempDir(), "channels.db") | ||
| 122 | s, err := Open(path) | ||
| 123 | if err != nil { | ||
| 124 | t.Fatal(err) | ||
| 125 | } | ||
| 126 | if err := s.Set("repo1", testChannel("stable", "v1.0.0")); err != nil { | ||
| 127 | t.Fatal(err) | ||
| 128 | } | ||
| 129 | if err := s.Close(); err != nil { | ||
| 130 | t.Fatal(err) | ||
| 131 | } | ||
| 132 | s, err = Open(path) | ||
| 133 | if err != nil { | ||
| 134 | t.Fatal(err) | ||
| 135 | } | ||
| 136 | defer s.Close() | ||
| 137 | if _, ok, err := s.Get("repo1", "stable"); err != nil || !ok { | ||
| 138 | t.Fatalf("after reopen = %v, %v", ok, err) | ||
| 139 | } | ||
| 140 | } | ||