@@ -17,6 +17,7 @@ import (
1717 "github.com/docker/model-runner/cmd/cli/desktop"
1818 "github.com/docker/model-runner/cmd/cli/pkg/types"
1919 "github.com/docker/model-runner/pkg/distribution/builder"
20+ "github.com/docker/model-runner/pkg/distribution/oci/reference"
2021 "github.com/docker/model-runner/pkg/distribution/registry"
2122 "github.com/stretchr/testify/require"
2223 "github.com/testcontainers/testcontainers-go"
@@ -110,6 +111,11 @@ func generateReferenceTestCases(info modelInfo) []referenceTestCase {
110111func setupTestEnv (t * testing.T ) * testEnv {
111112 ctx := context .Background ()
112113
114+ // Set environment variables for the test process to match the DMR container.
115+ // This ensures CLI functions use the same default registry when parsing references.
116+ t .Setenv ("DEFAULT_REGISTRY" , "registry.local:5000" )
117+ t .Setenv ("INSECURE_REGISTRY" , "true" )
118+
113119 // Create a custom network for container communication
114120 net , err := network .New (ctx )
115121 require .NoError (t , err )
@@ -1037,7 +1043,7 @@ func TestIntegration_PackageModel(t *testing.T) {
10371043 model , err := env .client .Inspect (targetTag , false )
10381044 require .NoError (t , err , "Failed to inspect packaged model by tag: %s" , targetTag )
10391045 require .NotEmpty (t , model .ID , "Model ID should not be empty" )
1040- require .Contains (t , model .Tags , targetTag , "Model should have the expected tag" )
1046+ require .Contains (t , model .Tags , normalizeRef ( t , targetTag ) , "Model should have the expected tag" )
10411047
10421048 t .Logf ("✓ Successfully packaged and tagged model: %s (ID: %s)" , targetTag , model .ID [7 :19 ])
10431049
@@ -1070,7 +1076,7 @@ func TestIntegration_PackageModel(t *testing.T) {
10701076 // Verify the model was loaded and tagged
10711077 model , err := env .client .Inspect (targetTag , false )
10721078 require .NoError (t , err , "Failed to inspect packaged model" )
1073- require .Contains (t , model .Tags , targetTag , "Model should have the expected tag" )
1079+ require .Contains (t , model .Tags , normalizeRef ( t , targetTag ) , "Model should have the expected tag" )
10741080
10751081 t .Logf ("✓ Successfully packaged model with context size: %s" , targetTag )
10761082
@@ -1100,7 +1106,7 @@ func TestIntegration_PackageModel(t *testing.T) {
11001106 // Verify the model was loaded and tagged
11011107 model , err := env .client .Inspect (targetTag , false )
11021108 require .NoError (t , err , "Failed to inspect packaged model" )
1103- require .Contains (t , model .Tags , targetTag , "Model should have the expected tag" )
1109+ require .Contains (t , model .Tags , normalizeRef ( t , targetTag ) , "Model should have the expected tag" )
11041110
11051111 t .Logf ("✓ Successfully packaged model with custom org: %s" , targetTag )
11061112
@@ -1118,3 +1124,12 @@ func TestIntegration_PackageModel(t *testing.T) {
11181124func int32ptr (n int32 ) * int32 {
11191125 return & n
11201126}
1127+
1128+ // normalizeRef normalizes a reference to its fully qualified form.
1129+ // This is used in tests to compare against the stored tags which are always normalized.
1130+ func normalizeRef (t * testing.T , ref string ) string {
1131+ t .Helper ()
1132+ parsed , err := reference .ParseReference (ref , registry .GetDefaultRegistryOptions ()... )
1133+ require .NoError (t , err , "Failed to parse reference: %s" , ref )
1134+ return parsed .String ()
1135+ }
0 commit comments