MCPcopy Create free account
hub / github.com/github/gh-aw / TestModelAliasesAWFConfigJSON

Function TestModelAliasesAWFConfigJSON

pkg/workflow/model_aliases_import_test.go:101–143  ·  view source on GitHub ↗

TestModelAliasesAWFConfigJSON verifies that model alias entries from imported workflows are merged into WorkflowData.ModelMappings during compilation and emitted under apiProxy.models in the AWF config JSON.

(t *testing.T)

Source from the content-addressed store, hash-verified

99// are merged into WorkflowData.ModelMappings during compilation and emitted under
100// apiProxy.models in the AWF config JSON.
101func TestModelAliasesAWFConfigJSON(t *testing.T) {
102 awfConfig := workflow.AWFCommandConfig{
103 EngineName: "copilot",
104 AllowedDomains: "github.com",
105 WorkflowData: &workflow.WorkflowData{
106 EngineConfig: &workflow.EngineConfig{ID: "copilot"},
107 NetworkPermissions: &workflow.NetworkPermissions{
108 Firewall: &workflow.FirewallConfig{Enabled: true},
109 },
110 // Simulate: import defines a new alias, main overrides a builtin.
111 ModelMappings: workflow.MergeImportedModelAliases(
112 []map[string][]string{
113 {"import-alias": {"import/model"}},
114 },
115 map[string][]string{
116 "haiku": {"main/haiku-override"},
117 },
118 ),
119 },
120 }
121
122 jsonStr, err := workflow.BuildAWFConfigJSON(awfConfig)
123 require.NoError(t, err, "BuildAWFConfigJSON should not return an error")
124
125 // models must appear nested under apiProxy
126 assert.Contains(t, jsonStr, `"models"`, "models section must be present under apiProxy in AWF config JSON")
127
128 // Verify that the alias map is correctly populated in WorkflowData.
129 mappings := awfConfig.WorkflowData.ModelMappings
130 require.NotNil(t, mappings, "ModelMappings should be set on WorkflowData")
131
132 // Imported alias is in the model mappings.
133 assert.Equal(t, []string{"import/model"}, mappings["import-alias"],
134 "import-alias from imported workflow should be in ModelMappings")
135
136 // Main workflow override wins over builtin haiku.
137 assert.Equal(t, []string{"main/haiku-override"}, mappings["haiku"],
138 "main workflow alias should override builtin haiku in ModelMappings")
139
140 // Other builtins preserved.
141 assert.NotEmpty(t, mappings["sonnet"], "builtin sonnet should still be in ModelMappings")
142 assert.NotEmpty(t, mappings["agent"], "builtin agent should still be in ModelMappings")
143}

Callers

nothing calls this directly

Calls 2

BuildAWFConfigJSONFunction · 0.92

Tested by

no test coverage detected