Skip to content

Commit

Permalink
added http mocks to the testing + Ihttoptions interface
Browse files Browse the repository at this point in the history
  • Loading branch information
RabbITCybErSeC committed Mar 5, 2024
1 parent 69ae672 commit 4993201
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 25 additions & 0 deletions test/mocks/mock_utils/http/mock_http.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package mock_executor

import (
"soarca/utils/http"

"github.com/stretchr/testify/mock"
)

type MockHttpOptions struct {
mock.Mock
}

type MockHttpRequest struct {
mock.Mock
}

func (httpOptions *MockHttpOptions) ExtractUrl() (string, error) {
args := httpOptions.Called()
return args.String(0), args.Error(1)
}

func (httpOptions *MockHttpRequest) Request(options http.HttpOptions) ([]byte, error) {
args := httpOptions.Called(options)
return args.Get(0).([]byte), args.Error(1)
}
5 changes: 4 additions & 1 deletion utils/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ type HttpOptions struct {
Auth *cacao.AuthenticationInformation
}

type IHttpOptions interface {
ExtractUrl() (string, error)
}
type IHttpRequest interface {
Request() ([]byte, error)
Request(httpOptions HttpOptions) ([]byte, error)
}

type HttpRequest struct{}
Expand Down

0 comments on commit 4993201

Please sign in to comment.