mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-30 04:20:20 +00:00
Improve temperature proxy workflow
This commit is contained in:
parent
eca1f272ca
commit
f9341ae1fc
17 changed files with 1217 additions and 34 deletions
45
internal/api/temperature_proxy_command_test.go
Normal file
45
internal/api/temperature_proxy_command_test.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/rcourtman/pulse-go-rewrite/internal/config"
|
||||
)
|
||||
|
||||
func TestHandleTemperatureProxyInstallCommand(t *testing.T) {
|
||||
cfg := &config.Config{PublicURL: "https://pulse.example:7655"}
|
||||
router := &Router{config: cfg}
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/temperature-proxy/install-command?node=pve-a", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
router.handleTemperatureProxyInstallCommand(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected status 200, got %d", rec.Code)
|
||||
}
|
||||
|
||||
var resp map[string]string
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
|
||||
t.Fatalf("failed to decode response: %v", err)
|
||||
}
|
||||
|
||||
if resp["node"] != "pve-a" {
|
||||
t.Fatalf("expected node pve-a, got %s", resp["node"])
|
||||
}
|
||||
|
||||
command := resp["command"]
|
||||
if command == "" {
|
||||
t.Fatalf("command missing in response")
|
||||
}
|
||||
if !strings.Contains(command, cfg.PublicURL) {
|
||||
t.Fatalf("command does not include pulse URL: %s", command)
|
||||
}
|
||||
if !strings.Contains(command, "--standalone --http-mode") {
|
||||
t.Fatalf("command missing expected flags: %s", command)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue