- Added .github/workflows/go-test.yml for automated CI testing using GitHub Actions - Implemented unit tests for: • utils/release.go (FetchLatestRelease) • routes/builds.go (buildsHandler) • routes/status.go (statusHandler) - Ensured tests run with go test ./... -v -cover - Included go vet and gofmt checks in the CI pipeline - Improved project reliability and continuous integration setup
25 lines
431 B
Go
25 lines
431 B
Go
package tests
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"newproxy/routes"
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func TestBuildsHandler(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
r := gin.Default()
|
|
routes.RegisterBuildsRoute(r)
|
|
|
|
req, _ := http.NewRequest("GET", "/client/builds.json", nil)
|
|
w := httptest.NewRecorder()
|
|
r.ServeHTTP(w, req)
|
|
|
|
if w.Code != http.StatusOK {
|
|
t.Errorf("Expected 200 OK, got %d", w.Code)
|
|
}
|
|
}
|