Remove dependency on ginkgo

This commit is contained in:
Francesco Renzi
2025-10-30 10:21:06 +00:00
parent 8b43e9e5c9
commit dd4c9f2481
3 changed files with 11 additions and 60 deletions
+5 -8
View File
@@ -4,10 +4,10 @@ import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
"github.com/golang-jwt/jwt/v4"
"github.com/onsi/ginkgo/v2"
"github.com/stretchr/testify/require"
)
@@ -17,16 +17,13 @@ import (
// /actions/runner-registration endpoints will be handled by the provided
// handler. The returned server is started and will be automatically closed
// when the test ends.
//
// TODO: this uses ginkgo interface _only_ to support our current controller tests
func New(t ginkgo.GinkgoTInterface, handler http.Handler, options ...actionsServerOption) *actionsServer {
func New(t testing.TB, handler http.Handler, options ...actionsServerOption) *actionsServer {
s := NewUnstarted(t, handler, options...)
s.Start()
return s
}
// TODO: this uses ginkgo interface _only_ to support our current controller tests
func NewUnstarted(t ginkgo.GinkgoTInterface, handler http.Handler, options ...actionsServerOption) *actionsServer {
func NewUnstarted(t testing.TB, handler http.Handler, options ...actionsServerOption) *actionsServer {
s := httptest.NewUnstartedServer(handler)
server := &actionsServer{
Server: s,
@@ -90,7 +87,7 @@ type actionsServer struct {
actionRegistrationTokenHandler http.HandlerFunc
}
func (s *actionsServer) setDefaults(t ginkgo.GinkgoTInterface) {
func (s *actionsServer) setDefaults(t testing.TB) {
if s.runnerRegistrationTokenHandler == nil {
s.runnerRegistrationTokenHandler = func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusCreated)
@@ -114,7 +111,7 @@ func (s *actionsServer) ConfigURLForOrg(org string) string {
return s.URL + "/" + org
}
func DefaultActionsToken(t ginkgo.GinkgoTInterface) string {
func DefaultActionsToken(t testing.TB) string {
claims := &jwt.RegisteredClaims{
IssuedAt: jwt.NewNumericDate(time.Now().Add(-10 * time.Minute)),
ExpiresAt: jwt.NewNumericDate(time.Now().Add(10 * time.Minute)),