rbstp commented on code in PR #8810:
URL:
https://github.com/apache/incubator-devlake/pull/8810#discussion_r3001906773
##########
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:
`gitea.internal.corp` is in the known hosts list, the URL would need to be
something else
--
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]