mirror of
https://github.com/cooperspencer/gickup
synced 2026-05-03 15:10:36 +02:00
de4f262e1f
* add additional tests * fix linter
29 lines
562 B
Go
29 lines
562 B
Go
package heartbeat
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"sync/atomic"
|
|
"testing"
|
|
|
|
"github.com/cooperspencer/gickup/types"
|
|
)
|
|
|
|
func TestSendCallsEachHeartbeatURL(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
var hits int32
|
|
|
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
|
atomic.AddInt32(&hits, 1)
|
|
w.WriteHeader(http.StatusNoContent)
|
|
}))
|
|
defer server.Close()
|
|
|
|
Send(types.HeartbeatConfig{URLs: []string{server.URL, server.URL}})
|
|
|
|
if got := atomic.LoadInt32(&hits); got != 2 {
|
|
t.Fatalf("hits = %d, want 2", got)
|
|
}
|
|
}
|