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

[feat] Add primary language field to repository GQL #323

Merged
merged 10 commits into from
Jan 3, 2024
20 changes: 19 additions & 1 deletion graphql_api/tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from freezegun import freeze_time

from codecov_auth.tests.factories import OwnerFactory
from core import models
from core.tests.factories import (
CommitFactory,
PullFactory,
Expand Down Expand Up @@ -69,6 +70,7 @@
graphToken
yaml
isATSConfigured
language
bot { username }
"""

Expand Down Expand Up @@ -97,7 +99,12 @@ def setUp(self):
@freeze_time("2021-01-01")
def test_when_repository_has_no_coverage(self):
repo = RepositoryFactory(
author=self.owner, active=True, private=True, name="a", yaml=self.yaml
author=self.owner,
active=True,
private=True,
name="a",
yaml=self.yaml,
language="rust",
)
profiling_token = RepositoryTokenFactory(
repository_id=repo.repoid, token_type="profiling"
Expand All @@ -124,6 +131,7 @@ def test_when_repository_has_no_coverage(self):
"graphToken": graphToken,
"yaml": "test: test\n",
"isATSConfigured": False,
"language": "rust",
"bot": None,
}

Expand All @@ -135,6 +143,7 @@ def test_when_repository_has_coverage(self):
private=True,
name="b",
yaml=self.yaml,
language="erlang",
)

hour_ago = datetime.datetime.now() - datetime.timedelta(hours=1)
Expand Down Expand Up @@ -175,6 +184,7 @@ def test_when_repository_has_coverage(self):
"graphToken": graphToken,
"yaml": "test: test\n",
"isATSConfigured": False,
"language": "erlang",
"bot": None,
}

Expand Down Expand Up @@ -439,3 +449,11 @@ def test_repository_has_ats_configured(self):

res = self.fetch_repository(repo.name)
assert res["isATSConfigured"] == True

def test_repository_get_language(self):
repo = RepositoryFactory(
author=self.owner, active=True, private=True, language="python"
)

res = self.fetch_repository(repo.name)
assert res["language"] == "python"
1 change: 1 addition & 0 deletions graphql_api/types/repository/repository.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Repository {
repositoryConfig: RepositoryConfig
staticAnalysisToken: String
isATSConfigured: Boolean
language: String
}

type PullConnection {
Expand Down
5 changes: 5 additions & 0 deletions graphql_api/types/repository/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ def resolve_repository_config(repository: Repository, info):
return repository


@repository_bindable.field("language")
def resolve_languate(repository: Repository, info):
return repository.language


repository_result_bindable = UnionType("RepositoryResult")


Expand Down