mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-27 15:41:41 +01:00
33 lines
634 B
Go
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))
|
|
|
|
}
|