Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetBatchResponseById doesn't pass type name to throwErrors #248

Closed
eric-millin opened this issue Dec 1, 2023 · 0 comments · Fixed by #249
Closed

GetBatchResponseById doesn't pass type name to throwErrors #248

eric-millin opened this issue Dec 1, 2023 · 0 comments · Fixed by #249
Assignees
Labels

Comments

@eric-millin
Copy link
Contributor

eric-millin commented Dec 1, 2023

You can see when using a debugger to step through this code

func TestGetResponseByIdFailedRequest(t *testing.T) {
	errorMapping := abstractions.ErrorMappings{
		"4XX": internal.CreateSampleErrorFromDiscriminatorValue,
		"5XX": internal.CreateSampleErrorFromDiscriminatorValue,
	}
	err := RegisterError("Userable", errorMapping)
	require.NoError(t, err)

	mockServer := makeMockRequest(200, getDummyJSON())
	defer mockServer.Close()

	mockPath := mockServer.URL + "/$batch"
	reqAdapter.SetBaseUrl(mockPath)

	reqInfo := getRequestInfo()
	batch := NewBatchRequest(reqAdapter)
	_, err = batch.AddBatchRequestStep(*reqInfo)
	require.NoError(t, err)

	resp, err := batch.Send(context.Background(), reqAdapter)
	require.NoError(t, err)
}

Change the following line: https://github.com/microsoftgraph/msgraph-sdk-go-core/blob/main/batch_requests.go#L269 to

		return res, throwErrors(item, reflect.TypeOf(new(T)).Elem().Name())

and you'll see that the error factories are returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants