Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-mckay committed Sep 5, 2024
1 parent 6f1592c commit a1e16f6
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions control_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package main

import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
)

Expand Down Expand Up @@ -82,28 +78,3 @@ func TestTransform(t *testing.T) {
t.Fail()
}
}

// this test requires priviledge
func TestControlHandler(t *testing.T) {
mockControlRequest := map[string]interface{}{
"unit": "user-1000.slice",
"property": map[string]interface{}{
"name": "CPUAccounting",
"value": "true",
},
"runtime": true,
}
payload, _ := json.Marshal(mockControlRequest)
req := httptest.NewRequest("POST", "/control", bytes.NewReader(payload))
w := httptest.NewRecorder()
ControlHandler(w, req)
resp := w.Result()
var cr controlResponse
err := json.NewDecoder(resp.Body).Decode(&cr)
if err != nil {
t.Fail()
}
if resp.StatusCode != http.StatusOK {
t.Fail()
}
}

0 comments on commit a1e16f6

Please sign in to comment.