Skip to content
Snippets Groups Projects
Commit d3f79d75 authored by Georges Racinet's avatar Georges Racinet
Browse files

Ref: proper not_found in FindBranch

Again one on the path to get functional tests pass.
parent cde272dc
No related branches found
No related tags found
1 merge request!13Helper for proper NOT_FOUND gRPC responses
Pipeline #12852 passed with warnings
......@@ -16,7 +16,10 @@
)
from hgext3rd.heptapod.branch import get_default_gitlab_branch
from ..errors import not_implemented
from ..errors import (
not_implemented,
not_found,
)
from ..stub.shared_pb2 import (
Branch,
GitCommit,
......@@ -244,6 +247,9 @@
return FindBranchResponse(branch=None)
head = gitlab_branch_head(repo, name)
if head is None:
return not_found(context, FindBranchResponse,
"GitLab branch %r not found" % name)
return FindBranchResponse(
branch=Branch(name=name, target_commit=message.commit(head)))
......
......@@ -4,6 +4,8 @@
# GNU General Public License version 2 or any later version.
#
# SPDX-License-Identifier: GPL-2.0-or-later
import grpc
import pytest
from mercurial import (
pycompat,
)
......@@ -114,6 +116,12 @@
name=b'refs/heads/branch/default'))
assert resp.branch == branch
with pytest.raises(grpc.RpcError) as exc_info:
ref_stub.FindBranch(
FindBranchRequest(repository=grpc_repo,
name=b'cannot-be-found'))
assert exc_info.value.code() == grpc.StatusCode.NOT_FOUND
resp = ref_stub.FindBranch(
FindBranchRequest(repository=grpc_repo,
name=b'refs/keeparound/012ca34fe56'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment