mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
47 lines
911 B
Go
47 lines
911 B
Go
package drone
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func Test_QueueInfo(t *testing.T) {
|
|
fixtureHandler := func(w http.ResponseWriter, r *http.Request) {
|
|
fmt.Fprint(w, `{
|
|
"pending": null,
|
|
"running": [
|
|
{
|
|
"id": "4696",
|
|
"data": "",
|
|
"labels": {
|
|
"platform": "linux/amd64",
|
|
"repo": "woodpecker-ci/woodpecker"
|
|
},
|
|
"Dependencies": [],
|
|
"DepStatus": {},
|
|
"RunOn": null
|
|
}
|
|
],
|
|
"stats": {
|
|
"worker_count": 3,
|
|
"pending_count": 0,
|
|
"waiting_on_deps_count": 0,
|
|
"running_count": 1,
|
|
"completed_count": 0
|
|
},
|
|
"Paused": false
|
|
}`)
|
|
}
|
|
|
|
ts := httptest.NewServer(http.HandlerFunc(fixtureHandler))
|
|
defer ts.Close()
|
|
|
|
client := NewClient(ts.URL, http.DefaultClient)
|
|
|
|
info, err := client.QueueInfo()
|
|
if info.Stats.Workers != 3 {
|
|
t.Errorf("Unexpected worker count: %v, %v", info, err)
|
|
}
|
|
}
|