// SPDX-License-Identifier: Apache-2.0
import { expect } from 'chai';
import { ImageReference } from '../../../../src/business/utils/image-reference.js';
describe('ImageReference', () => {
    describe('validateImageTag', () => {
        it('should accept valid tags', () => {
            expect(ImageReference.validateImageTag('latest', 'latest')).to.equal('latest');
            expect(ImageReference.validateImageTag('0.77.0-SNAPSHOT', '0.77.0-SNAPSHOT')).to.equal('0.77.0-SNAPSHOT');
        });
        it('should reject invalid tags', () => {
            expect(() => {
                ImageReference.validateImageTag('', '');
            }).to.throw('Invalid image tag');
            expect(() => {
                ImageReference.validateImageTag('bad/tag', 'bad/tag');
            }).to.throw('Invalid image tag');
        });
    });
    describe('parseImageReference', () => {
        it('should parse explicit registry with implicit tag', () => {
            const parsed = ImageReference.parseImageReference('docker.io/library/v400.0');
            expect(parsed.registry).to.equal('docker.io');
            expect(parsed.repository).to.equal('library/v400.0');
            expect(parsed.tag).to.equal('latest');
        });
        it('should parse docker hub shorthand', () => {
            const parsed = ImageReference.parseImageReference('redis:7');
            expect(parsed.registry).to.equal('docker.io');
            expect(parsed.repository).to.equal('library/redis');
            expect(parsed.tag).to.equal('7');
        });
        it('should parse registry with port', () => {
            const parsed = ImageReference.parseImageReference('localhost:5000/org/relay:v1');
            expect(parsed.registry).to.equal('localhost:5000');
            expect(parsed.repository).to.equal('org/relay');
            expect(parsed.tag).to.equal('v1');
        });
        it('should reject digest references', () => {
            expect(() => {
                ImageReference.parseImageReference('ghcr.io/org/relay@sha256:123');
            }).to.throw('Digest-based image references are not supported');
        });
        it('should reject plain image values without separators', () => {
            expect(() => {
                ImageReference.parseImageReference('latest');
            }).to.throw('Invalid image reference format');
        });
    });
});
//# sourceMappingURL=image-reference.test.js.map