feat: auto configure console queue
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package httpserver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
@@ -32,3 +33,26 @@ func TestConsoleRedirectsWithoutTouchingAPIAuthentication(t *testing.T) {
|
||||
t.Fatalf("redirect = %d %q", w.Code, w.Header().Get("Location"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsoleConfigReadsOnlyDefaultQueue(t *testing.T) {
|
||||
t.Setenv("ORBIT_CONSOLE_QUEUE_ID", "queue-default")
|
||||
server := New("127.0.0.1:0", nil)
|
||||
r := httptest.NewRequest(http.MethodGet, "/console/config", nil)
|
||||
w := httptest.NewRecorder()
|
||||
server.Handler.ServeHTTP(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, want 200", w.Code)
|
||||
}
|
||||
if got := w.Header().Get("Cache-Control"); got != "no-store" {
|
||||
t.Fatalf("cache control = %q, want no-store", got)
|
||||
}
|
||||
var payload struct {
|
||||
DefaultQueueID string `json:"default_queue_id"`
|
||||
}
|
||||
if err := json.NewDecoder(w.Body).Decode(&payload); err != nil {
|
||||
t.Fatalf("decode config: %v", err)
|
||||
}
|
||||
if payload.DefaultQueueID != "queue-default" {
|
||||
t.Fatalf("default queue = %q, want queue-default", payload.DefaultQueueID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user