Skip to content

Commit

Permalink
Fix git repo URL asserts in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-tkachenko-datadog committed Jan 25, 2024
1 parent c751e83 commit ae44b1d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void testTraces() throws Exception {
assertEquals(1, spans.size());

final TraceSpan buildSpan = spans.get(0);
assertGitVariablesOnSpan(buildSpan, "master", localGitRepoPath.getRemote());
assertGitVariablesOnSpan(buildSpan, "master", toUrl(localGitRepoPath.getRemote()));
final Map<String, String> meta = buildSpan.getMeta();
final Map<String, Double> metrics = buildSpan.getMetrics();
assertEquals(BuildPipelineNode.NodeType.PIPELINE.getBuildLevel(), meta.get(CITags._DD_CI_BUILD_LEVEL));
Expand Down Expand Up @@ -228,7 +228,7 @@ public void testGitDefaultBranch() throws Exception {
assertEquals(1, spans.size());

final TraceSpan buildSpan = spans.get(0);
assertGitVariablesOnSpan(buildSpan, "hardcoded-master", localGitRepoPath.getRemote());
assertGitVariablesOnSpan(buildSpan, "hardcoded-master", toUrl(localGitRepoPath.getRemote()));
}

@Test
Expand Down Expand Up @@ -259,7 +259,7 @@ public void testUserSuppliedGitWithoutCommitInfo() throws Exception {
assertEquals(1, spans.size());

final TraceSpan buildSpan = spans.get(0);
assertGitVariablesOnSpan(buildSpan, "hardcoded-master", localGitRepoPath.getRemote());
assertGitVariablesOnSpan(buildSpan, "hardcoded-master", toUrl(localGitRepoPath.getRemote()));
}

@Test
Expand Down Expand Up @@ -443,7 +443,7 @@ public void testGitAlternativeRepoUrlWebhook() throws Exception {
assertEquals(1, webhooks.size());

final JSONObject webhook = webhooks.get(0);
assertGitVariablesOnWebhook(webhook, "master", localGitRepoPath.getRemote());
assertGitVariablesOnWebhook(webhook, "master", toUrl(localGitRepoPath.getRemote()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public void testIntegrationGitInfo() throws Exception {
final List<TraceSpan> spans = clientStub.getSpans();
assertEquals(3, spans.size());
final TraceSpan buildSpan = spans.get(0);
assertGitVariablesOnSpan(buildSpan, "master", localGitRepoPath.getRemote());
assertGitVariablesOnSpan(buildSpan, "master", toUrl(localGitRepoPath.getRemote()));
}

@NotNull
Expand Down Expand Up @@ -320,7 +320,7 @@ public void testIntegrationGitInfoWebhooks() throws Exception {
clientStub.waitForWebhooks(3);
final List<JSONObject> webhook = clientStub.getWebhooks();
assertEquals(3, webhook.size());
assertGitVariablesOnWebhook(webhook.get(0), "master", localGitRepoPath.getRemote());
assertGitVariablesOnWebhook(webhook.get(0), "master", toUrl(localGitRepoPath.getRemote()));
}

@Test
Expand Down Expand Up @@ -351,7 +351,7 @@ public void testIntegrationGitInfoDefaultBranchEnvVar() throws Exception {
final List<TraceSpan> spans = clientStub.getSpans();
assertEquals(3, spans.size());
final TraceSpan buildSpan = spans.get(0);
assertGitVariablesOnSpan(buildSpan, "hardcoded-master", localGitRepoPath.getRemote());
assertGitVariablesOnSpan(buildSpan, "hardcoded-master", toUrl(localGitRepoPath.getRemote()));
}

@Test
Expand Down Expand Up @@ -494,7 +494,7 @@ public void testUserSuppliedGitWithoutCommitInfo() throws Exception {
final List<TraceSpan> spans = clientStub.getSpans();
assertEquals(3, spans.size());
final TraceSpan buildSpan = spans.get(0);
assertGitVariablesOnSpan(buildSpan, "master", localGitRepoPath.getRemote());
assertGitVariablesOnSpan(buildSpan, "master", toUrl(localGitRepoPath.getRemote()));
final Map<String, String> meta = buildSpan.getMeta();
assertEquals("0.1.0", meta.get(CITags.GIT_TAG));
}
Expand Down Expand Up @@ -537,7 +537,7 @@ public void testUserSuppliedGitWithoutCommitInfoWebhooks() throws Exception {
final List<JSONObject> webhooks = clientStub.getWebhooks();
assertEquals(3, webhooks.size());
final JSONObject webhook = webhooks.get(0);
assertGitVariablesOnWebhook(webhook, "master", localGitRepoPath.getRemote());
assertGitVariablesOnWebhook(webhook, "master", toUrl(localGitRepoPath.getRemote()));
assertEquals("0.1.0", webhook.getJSONObject("git").get("tag"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public abstract class DatadogTraceAbstractTest {

protected void assertGitVariablesOnSpan(TraceSpan span, String defaultBranch, String localGitRepoPath) {
protected void assertGitVariablesOnSpan(TraceSpan span, String defaultBranch, String gitRepoUrl) {
final Map<String, String> meta = span.getMeta();
assertEquals("Initial commit\n", meta.get(CITags.GIT_COMMIT_MESSAGE));
assertEquals("John Doe", meta.get(CITags.GIT_COMMIT_AUTHOR_NAME));
Expand All @@ -30,11 +30,11 @@ protected void assertGitVariablesOnSpan(TraceSpan span, String defaultBranch, St
assertEquals("401d997a6eede777602669ccaec059755c98161f", meta.get(CITags.GIT_COMMIT__SHA));
assertEquals("401d997a6eede777602669ccaec059755c98161f", meta.get(CITags.GIT_COMMIT_SHA));
assertEquals("master", meta.get(CITags.GIT_BRANCH));
assertEquals("file://" + localGitRepoPath, meta.get(CITags.GIT_REPOSITORY_URL));
assertEquals(gitRepoUrl, meta.get(CITags.GIT_REPOSITORY_URL));
assertEquals(defaultBranch, meta.get(CITags.GIT_DEFAULT_BRANCH));
}

protected void assertGitVariablesOnWebhook(JSONObject webhook, String defaultBranch, String localGitRepoPath) {
protected void assertGitVariablesOnWebhook(JSONObject webhook, String defaultBranch, String gitRepoUrl) {
JSONObject meta = webhook.getJSONObject("git");
assertEquals("Initial commit\n", meta.get("message"));
assertEquals("John Doe", meta.get("author_name"));
Expand All @@ -45,7 +45,7 @@ protected void assertGitVariablesOnWebhook(JSONObject webhook, String defaultBra
assertEquals("2020-10-08T07:49:32.000Z", meta.get("commit_time"));
assertEquals("401d997a6eede777602669ccaec059755c98161f", meta.get("sha"));
assertEquals("master", meta.get("branch"));
assertEquals("file://" + localGitRepoPath, meta.get("repository_url"));
assertEquals(gitRepoUrl, meta.get("repository_url"));
assertEquals(defaultBranch, meta.get("default_branch"));
}

Expand Down

0 comments on commit ae44b1d

Please sign in to comment.