prometheus-paperless-exporter/collector_test.go
Michael Hanselmann f2cc188833
Some checks failed
Run tests / test (push) Has been cancelled
Release / release (push) Has been cancelled
Initial commit
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2023-07-03 00:16:08 +02:00

31 lines
651 B
Go

package main
import (
"io"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/hansmi/paperhooks/pkg/client"
"github.com/hansmi/prometheus-paperless-exporter/internal/testutil"
)
func TestCollector(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "{}")
}))
t.Cleanup(ts.Close)
cl := client.New(client.Options{
BaseURL: ts.URL,
})
c := newCollector(cl, time.Minute)
testutil.CollectAndCompare(t, c, `
# HELP paperless_task_status_info Task status names.
# TYPE paperless_task_status_info gauge
paperless_task_status_info{status="success"} 1
`)
}