vemulaanvesh commented on code in PR #8810:
URL: 
https://github.com/apache/incubator-devlake/pull/8810#discussion_r3004021400


##########
backend/plugins/argocd/tasks/sync_operation_extractor_test.go:
##########
@@ -76,3 +76,89 @@ func TestCollectContainerImages_FallbackRevisionAndSummary(t 
*testing.T) {
        // normalizeImages: dedupe + sort
        assert.Equal(t, []string{"a", "b"}, normalizeImages([]string{"b", "a", 
"b"}))
 }
+
+// ── resolveMultiSourceRevision 
────────────────────────────────────────────────
+
+func TestResolveMultiSourceRevision_GitHubSourceWins(t *testing.T) {
+       // Typical MTTN pattern: Helm chart (GCS) + git values repo (GitHub).
+       revisions := []string{"2.6.2", 
"5dd95b4efd7e9b668c361bbddb8d7f1e56c32ac1"}
+       sources := []ArgocdApiSyncSource{
+               {RepoURL: "gs://charts-example-net/infra/stable", Chart: 
"generic-service"},
+               {RepoURL: "https://github.com/example/my-repo"},
+       }
+       got := resolveMultiSourceRevision(revisions, sources)
+       assert.Equal(t, "5dd95b4efd7e9b668c361bbddb8d7f1e56c32ac1", got)
+}
+
+func TestResolveMultiSourceRevision_GitLabSourceWins(t *testing.T) {
+       revisions := []string{"1.0.0", 
"aabbccdd11223344aabbccdd11223344aabbccdd"}
+       sources := []ArgocdApiSyncSource{
+               {RepoURL: "oci://registry.example.com/charts", Chart: "app"},
+               {RepoURL: "https://gitlab.com/example/config"},
+       }
+       got := resolveMultiSourceRevision(revisions, sources)
+       assert.Equal(t, "aabbccdd11223344aabbccdd11223344aabbccdd", got)
+}
+
+func TestResolveMultiSourceRevision_FallbackToAnySHA(t *testing.T) {
+       // No known git hosting service in sources; still picks the SHA by 
shape.
+       revisions := []string{"1.2.3", 
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"}
+       sources := []ArgocdApiSyncSource{
+               {RepoURL: "gs://bucket/charts"},
+               {RepoURL: "https://gitea.internal.corp/team/config"},

Review Comment:
   Good catch, thank you! `gitea.internal.corp` contains `gitea.` which matched 
our known-host heuristic (Pass 1), so the test was never actually exercising 
the fallback path despite its name.
   
   Fixed in the latest commit: replaced the URL with 
`https://git.acme-corp.internal/team/config`, which has no known-host prefix 
(`gitea.`, `github.com`, etc.), no chart-registry prefix (`gs://`, `oci://`, 
`s3://`), and no `.git` suffix — so `isGitHostedURL()` correctly returns 
`false` and `resolveMultiSourceRevision()` genuinely falls through to the 
SHA-shape fallback (Pass 2) to pick the 40-hex commit.
   
   Could you take another look when you get a chance? Appreciate the review!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to