You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into this when trying to create mocked unit tests. I end up needing to define the inline struct of a SearchResp (which leads to defining the "total" field twice) every time I try to instantiate the SearchResp. Everything below is before I put any meaningful data into the response.
expectedSearchOutput: &opensearchapi.SearchResp{
Hits: struct {
Total struct {
Value int `json:"value"`
Relation string `json:"relation"`
} `json:"total"`
MaxScore float32 `json:"max_score"`
Hits []opensearchapi.SearchHit `json:"hits"`
}{
Total: struct {
Value int `json:"value"`
Relation string `json:"relation"`
}{
Value: 0,
Relation: "",
},
MaxScore: 0.0,
Hits: nil,
},
},
Is your feature request related to a problem?
For example the SnapshotGetResp struct has a field named Snapshots which is an array of struct.
I want to write a functions that uses this struct, but it can't be used as it is not its own type.
So it can't be referenced in the function arguments.
https://github.com/opensearch-project/opensearch-go/blob/main/opensearchapi/api_snapshot-get.go#L43
What solution would you like?
All structs inside Resp types should become their own type.
What alternatives have you considered?
Otherwise I need to redefine the struct on my end instead of using the lib.
Do you have any additional context?
The text was updated successfully, but these errors were encountered: