Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e6eee0b9c | ||
|
|
da206a5237 |
@@ -11,6 +11,43 @@ import (
|
||||
|
||||
const testRepository = "https://git.example.org/me/nixos-router"
|
||||
|
||||
// While the look at the repository runs, the page is covered by the same kind
|
||||
// of box as an update, and keeps asking for itself until it is done.
|
||||
func TestLookingAtTheRepositoryShowsABox(t *testing.T) {
|
||||
a, sys := newTestApp(t)
|
||||
sys.RepositoryFile = filepath.Join(t.TempDir(), "router-update-repository")
|
||||
os.WriteFile(sys.RepositoryFile, []byte(testRepository), 0o644)
|
||||
a.sys = sys
|
||||
orig := unitProperty
|
||||
state := "inactive"
|
||||
unitProperty = func(unit, prop string) string {
|
||||
if unit == gitCheckUnit && prop == "ActiveState" {
|
||||
return state
|
||||
}
|
||||
return ""
|
||||
}
|
||||
defer func() { unitProperty = orig }()
|
||||
h := a.routes()
|
||||
cookie := login(t, h)
|
||||
|
||||
body := do(h, "GET", "/update", nil, cookie).Body.String()
|
||||
if strings.Contains(body, "Looking at the repository…") || strings.Contains(body, "data-live") {
|
||||
t.Fatalf("a box with nothing running:\n%s", body)
|
||||
}
|
||||
if !strings.Contains(body, "Look for a newer release") {
|
||||
t.Fatalf("no button:\n%s", body)
|
||||
}
|
||||
|
||||
state = "activating"
|
||||
body = do(h, "GET", "/update", nil, cookie).Body.String()
|
||||
if !strings.Contains(body, "Looking at the repository…") || !strings.Contains(body, `class="upload-overlay"`) || !strings.Contains(body, "data-live") {
|
||||
t.Fatalf("no box while looking:\n%s", body)
|
||||
}
|
||||
if !strings.Contains(body, testRepository) {
|
||||
t.Fatalf("the box does not say where it looks:\n%s", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdatesFromGit(t *testing.T) {
|
||||
a, sys := newTestApp(t)
|
||||
dir := t.TempDir()
|
||||
|
||||
@@ -49,7 +49,8 @@ func command(name string, args ...string) (string, error) {
|
||||
return strings.TrimSpace(string(out)), err
|
||||
}
|
||||
|
||||
func unitProperty(unit, prop string) string {
|
||||
// unitProperty is a property of a systemd unit (replaced in tests).
|
||||
var unitProperty = func(unit, prop string) string {
|
||||
out, _ := command("systemctl", "show", "--value", "-p", prop, unit)
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -22,6 +22,16 @@
|
||||
<p class="muted">The page reloads when it is done. The web UI restarts when an upgrade is switched on, and you log in again.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{else if $u.GitRun.Running}}
|
||||
<div class="upload-overlay" role="dialog" aria-modal="true">
|
||||
<div class="upload-card wide">
|
||||
<h2>Looking at the repository…</h2>
|
||||
<progress max="100"></progress>
|
||||
<p>Reading the release tags of <code>{{$u.Repository}}</code>.</p>
|
||||
{{if $u.GitRun.Log}}<pre class="log">{{$u.GitRun.Log}}</pre>{{end}}
|
||||
<p class="muted">The page reloads when it is done.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{else if $u.Pending}}
|
||||
<section class="pending"><h2>Waiting for confirmation</h2>
|
||||
<p>A new system is active and not confirmed yet. Confirm it on the <a href="/">Overview</a>, or the router goes back to the
|
||||
|
||||
Reference in New Issue
Block a user