Files
sablier/app/http/routes/version_test.go
Alexis Couvreur 8844a36e4a refactor(logging): use slog instead of logrus (#501)
Everything uses slog now and the logger is part of every struct
2025-02-02 23:01:51 -05:00

33 lines
634 B
Go

package routes
import (
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
"github.com/sablierapp/sablier/version"
"gotest.tools/v3/assert"
)
func TestGetVersion(t *testing.T) {
gin.SetMode(gin.TestMode)
version.Branch = "testing"
version.Revision = "8ffebca"
recorder := httptest.NewRecorder()
c, _ := gin.CreateTestContext(recorder)
expected, _ := json.Marshal(version.Map())
GetVersion(c)
res := recorder.Result()
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
assert.Equal(t, res.StatusCode, http.StatusOK)
assert.Equal(t, string(data), string(expected))
}