forked from nokia/restful
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_ping_test.go
More file actions
32 lines (25 loc) · 801 Bytes
/
client_ping_test.go
File metadata and controls
32 lines (25 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2021-2024 Nokia
// Licensed under the BSD 3-Clause License.
// SPDX-License-Identifier: BSD-3-Clause
package restful
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPingListOK(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}))
defer srv.Close()
assert.NoError(t, PingList(context.Background(), []string{srv.URL, srv.URL, srv.URL, srv.URL, srv.URL}))
}
func TestPingListNOK(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
}))
defer srv.Close()
assert.Error(t, PingList(context.Background(), []string{srv.URL}))
}