Uploaded image for project: 'Red Hat OpenShift Control Planes'
  1. Red Hat OpenShift Control Planes
  2. CNTRLPLANE-2794

Re-add TestGetDigest and TestGetManifest with mockgen mocks instead of real registry calls

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Normal Normal
    • None
    • None
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False
    • None
    • None
    • None
    • None

      In commit 2c734e72a, TestGetDigest and TestGetManifest were removed from support/util/imagemetadata_test.go because they made real HTTP calls to quay.io, violating unit testing principles. While removing them was correct to unblock CI, the code paths exercised by those tests (GetDigest, GetManifest, cache behavior, override fallback) are no longer covered by any unit test.

      Re-add the tests using mockgen-generated mocks for distribution.Repository and distribution.TagService so that no network calls are made and digests are deterministic.

      Implementation approach:

      • Add injectable repoSetupFn field to RegistryClientImageMetadataProvider
      • Add go:generate directive for mockgen following existing convention in support/releaseinfo/releaseinfo.go
      • Rewrite tests using gomock MockRepository and MockTagService
      • Clear digestCache and manifestsCache between test cases for isolation

      Reference: https://github.com/openshift/hypershift/commit/2c734e72a5b96473ee4ca18d98c042d857ad0a2f

              jparrill@redhat.com Juan Manuel Parrilla Madrid
              jparrill@redhat.com Juan Manuel Parrilla Madrid
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: