draft test

This commit is contained in:
mr
2025-06-16 11:24:39 +02:00
parent 2a0ab8e549
commit 48299810e0
32 changed files with 1142 additions and 47 deletions

View File

@@ -47,12 +47,19 @@ func ToMethod(str string) METHOD {
return GET
}
type HTTPCallerITF interface {
GetUrls() map[DataType]map[METHOD]string
CallGet(url string, subpath string, types ...string) ([]byte, error)
CallPost(url string, subpath string, body interface{}, types ...string) ([]byte, error)
CallDelete(url string, subpath string) ([]byte, error)
}
var HTTPCallerInstance = &HTTPCaller{} // Singleton instance of the HTTPCaller
type HTTPCaller struct {
URLS map[DataType]map[METHOD]string // Map of the different methods and their urls
Disabled bool // Disabled flag
LastResults map[string]interface{} // Used to store information regarding the last execution of a given method on a given data type
URLS map[DataType]map[METHOD]string // Map of the different methods and their urls
Disabled bool // Disabled flag
LastResults map[string]interface{} // Used to store information regarding the last execution of a given method on a given data type
}
// NewHTTPCaller creates a new instance of the HTTP Caller
@@ -63,8 +70,12 @@ func NewHTTPCaller(urls map[DataType]map[METHOD]string) *HTTPCaller {
}
}
// Creates a copy of the current caller, in order to have parallelized executions without race condition
func (c* HTTPCaller) DeepCopy(dst HTTPCaller) error {
func (c *HTTPCaller) GetUrls() map[DataType]map[METHOD]string {
return c.URLS
}
// Creates a copy of the current caller, in order to have parallelized executions without race condition
func (c *HTTPCaller) DeepCopy(dst HTTPCaller) error {
bytes, err := json.Marshal(c)
if err != nil {
return err
@@ -219,4 +230,4 @@ func (caller *HTTPCaller) StoreResp(resp *http.Response) error {
caller.LastResults["body"] = data
return nil
}
}