site/ is the website: a static page plus a worker that turns the newest release of yetone/magpie-releases into an update feed (/api/latest, with every file's SHA-256), stable download links and an install script. The app asks the feed at start-up and every six hours, downloads a newer version in the background, and installs it on Restart to Update or on quit. A download must match its checksum and be signed by the same team as the app it replaces. `magpie update` does the same from a terminal and replaces a bare binary in place.
33 lines
786 B
Go
33 lines
786 B
Go
package update
|
|
|
|
import "testing"
|
|
|
|
func TestNewer(t *testing.T) {
|
|
for _, c := range []struct {
|
|
a, b string
|
|
want bool
|
|
}{
|
|
{"0.2.0", "0.1.0", true},
|
|
{"0.1.0", "0.2.0", false},
|
|
{"0.1.0", "0.1.0", false},
|
|
{"v0.10.0", "0.9.9", true},
|
|
{"1.0.0", "1.0.0-rc.1", true},
|
|
{"1.0.0-rc.1", "1.0.0", false},
|
|
{"1.0.0-rc.2", "1.0.0-rc.1", true},
|
|
{"0.2.0", "dev", false},
|
|
{"0.2.0", "0bcb2cc-dirty", false},
|
|
} {
|
|
if got := Newer(c.a, c.b); got != c.want {
|
|
t.Errorf("Newer(%q, %q) = %v, want %v", c.a, c.b, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestReleased(t *testing.T) {
|
|
for v, want := range map[string]bool{"0.1.0": true, "v1.2.3": true, "dev": false, "0bcb2cc-dirty": false, "v0.1.0-3-g0bcb2cc": false} {
|
|
if Released(v) != want {
|
|
t.Errorf("Released(%q) != %v", v, want)
|
|
}
|
|
}
|
|
}
|