2026-05-21 23:52:39 +00:00
|
|
|
//go:build e2e
|
|
|
|
|
|
|
|
|
|
package e2e
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"net/http"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestHealth_Ping(t *testing.T) {
|
2026-05-22 09:18:36 +00:00
|
|
|
e2eStep(t, "N-01", "GET", "/api/v1/health", "Ping 回 200 + envelope code=102000")
|
2026-05-21 23:52:39 +00:00
|
|
|
c := NewClient(t)
|
|
|
|
|
env := c.DoExpectOK(t, http.MethodGet, "/api/v1/health", nil, false)
|
|
|
|
|
var data map[string]any
|
|
|
|
|
require.NoError(t, json.Unmarshal(env.Data, &data))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestHealth_NoAuthRequired(t *testing.T) {
|
2026-05-22 09:18:36 +00:00
|
|
|
e2eStep(t, "N-02", "GET", "/api/v1/health", "未帶 Bearer 也能通過")
|
2026-05-21 23:52:39 +00:00
|
|
|
c := NewClient(t)
|
|
|
|
|
resp, env := c.Do(t, http.MethodGet, "/api/v1/health", nil, false)
|
|
|
|
|
require.Equal(t, http.StatusOK, resp.StatusCode)
|
|
|
|
|
require.Equal(t, int64(successCode), env.Code)
|
|
|
|
|
}
|