@@ -53,56 +53,6 @@ func TestBuiltinModelAliases(t *testing.T) {
5353 assert .NotEqual (t , aliases ["sonnet" ], aliases2 ["sonnet" ], "BuiltinModelAliases should return a fresh copy each time" )
5454}
5555
56- // TestMergeModelAliases verifies that frontmatter-defined aliases are merged on top
57- // of the builtins.
58- func TestMergeModelAliases (t * testing.T ) {
59- t .Run ("nil frontmatter returns all builtins" , func (t * testing.T ) {
60- merged := MergeModelAliases (nil )
61- builtins := BuiltinModelAliases ()
62- assert .Len (t , merged , len (builtins ), "nil frontmatter should return exactly the builtins" )
63- for k , v := range builtins {
64- assert .Equal (t , v , merged [k ], "builtin alias %q should be present unchanged" , k )
65- }
66- })
67-
68- t .Run ("empty frontmatter returns all builtins" , func (t * testing.T ) {
69- merged := MergeModelAliases (map [string ][]string {})
70- builtins := BuiltinModelAliases ()
71- assert .Len (t , merged , len (builtins ), "empty frontmatter should return exactly the builtins" )
72- })
73-
74- t .Run ("frontmatter override replaces builtin entry" , func (t * testing.T ) {
75- custom := map [string ][]string {
76- "sonnet" : {"myvendor/sonnet-custom" },
77- }
78- merged := MergeModelAliases (custom )
79- assert .Equal (t , []string {"myvendor/sonnet-custom" }, merged ["sonnet" ],
80- "frontmatter override should replace the builtin sonnet alias" )
81- // Other builtins should be unaffected.
82- assert .NotEmpty (t , merged ["haiku" ], "haiku builtin should still be present" )
83- })
84-
85- t .Run ("frontmatter adds new alias" , func (t * testing.T ) {
86- custom := map [string ][]string {
87- "my-alias" : {"copilot/my-model" },
88- }
89- merged := MergeModelAliases (custom )
90- assert .Equal (t , []string {"copilot/my-model" }, merged ["my-alias" ],
91- "new frontmatter alias should be present in merged map" )
92- // Builtins should still be present.
93- assert .NotEmpty (t , merged ["sonnet" ], "sonnet builtin should still be present" )
94- })
95-
96- t .Run ("default policy key is supported" , func (t * testing.T ) {
97- custom := map [string ][]string {
98- "" : {"sonnet" , "gpt-5-codex" },
99- }
100- merged := MergeModelAliases (custom )
101- assert .Equal (t , []string {"sonnet" , "gpt-5-codex" }, merged ["" ],
102- "default policy (empty key) should be stored and returned" )
103- })
104- }
105-
10656// TestBuildAWFConfigJSON_ModelsSection verifies model alias behaviour in BuildAWFConfigJSON.
10757//
10858// NOTE: The "models" field is intentionally excluded from the AWF config JSON until the
@@ -120,7 +70,7 @@ func TestBuildAWFConfigJSON_ModelsSection(t *testing.T) {
12070 NetworkPermissions : & NetworkPermissions {
12171 Firewall : & FirewallConfig {Enabled : true },
12272 },
123- ModelMappings : MergeModelAliases ( nil ),
73+ ModelMappings : MergeImportedModelAliases ( nil , nil ),
12474 },
12575 }
12676
@@ -153,7 +103,7 @@ func TestBuildAWFConfigJSON_ModelsSection(t *testing.T) {
153103 NetworkPermissions : & NetworkPermissions {
154104 Firewall : & FirewallConfig {Enabled : true },
155105 },
156- ModelMappings : MergeModelAliases ( custom ),
106+ ModelMappings : MergeImportedModelAliases ( nil , custom ),
157107 },
158108 }
159109
0 commit comments