feat: redesign responsive console and fix restore regressions
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.misaka.ren/m1saka/dsh-web/internal/docker"
|
||||
"git.misaka.ren/m1saka/dsh-web/internal/store"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"mime/multipart"
|
||||
@@ -20,6 +21,47 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestConfigStopAlreadyStopped(t *testing.T) {
|
||||
for _, state := range []string{`{}`, `{"Running":true}`, `{"Paused":true}`, `{"Restarting":true}`} {
|
||||
t.Run(state, func(t *testing.T) {
|
||||
inspected := false
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == "POST" {
|
||||
w.WriteHeader(http.StatusNotModified)
|
||||
return
|
||||
}
|
||||
inspected = true
|
||||
fmt.Fprintf(w, `{"State":%s}`, state)
|
||||
}))
|
||||
defer srv.Close()
|
||||
a := &API{docker: docker.New(srv.URL)}
|
||||
err := a.configStop(context.Background(), "test")
|
||||
if !inspected || (err == nil) != (state == `{}`) {
|
||||
t.Fatalf("inspected=%v error=%v", inspected, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigEmptyProfileRoundTrip(t *testing.T) {
|
||||
if os.Geteuid() != 0 {
|
||||
t.Skip("requires chown")
|
||||
}
|
||||
a, i, home := configTestAPI(t, false)
|
||||
w := configCall(a, i, "GET", "profile", "")
|
||||
if w.Code != 200 {
|
||||
t.Fatal(w.Code, w.Body.String())
|
||||
}
|
||||
w = configCall(a, i, "PUT", "profile", w.Body.String())
|
||||
if w.Code != 200 {
|
||||
t.Fatal(w.Code, w.Body.String())
|
||||
}
|
||||
content, err := os.ReadFile(filepath.Join(home, "profiles/web/cordis.patch.yml"))
|
||||
if err != nil || string(content) != "[]\n" {
|
||||
t.Fatalf("content=%q error=%v", content, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigPasswordBackupImport(t *testing.T) {
|
||||
if os.Geteuid() != 0 {
|
||||
t.Skip("requires chown")
|
||||
|
||||
Reference in New Issue
Block a user