@@ -3,6 +3,7 @@ package proxy
33import (
44 "os"
55 "path/filepath"
6+ "strings"
67 "testing"
78
89 "github.com/stretchr/testify/assert"
@@ -138,14 +139,6 @@ groups:
138139}
139140
140141func TestConfig_GroupMemberIsUnique (t * testing.T ) {
141- // Create a temporary YAML file for testing
142- tempDir , err := os .MkdirTemp ("" , "test-config" )
143- if err != nil {
144- t .Fatalf ("Failed to create temporary directory: %v" , err )
145- }
146- defer os .RemoveAll (tempDir )
147-
148- tempFile := filepath .Join (tempDir , "config.yaml" )
149142 content := `
150143models:
151144 model1:
@@ -171,15 +164,32 @@ groups:
171164 exclusive: false
172165 members: ["model2"]
173166`
167+ // Load the config and verify
168+ _ , err := LoadConfigFromReader (strings .NewReader (content ))
169+ assert .Equal (t , "model member model2 is used in multiple groups: group1 and group2" , err .Error ())
174170
175- if err := os .WriteFile (tempFile , []byte (content ), 0644 ); err != nil {
176- t .Fatalf ("Failed to write temporary file: %v" , err )
177- }
171+ }
178172
179- // Load the config and verify
180- _ , err = LoadConfig (tempFile )
181- assert .NotNil (t , err )
173+ func TestConfig_ModelAliasesAreUnique (t * testing.T ) {
174+ content := `
175+ models:
176+ model1:
177+ cmd: path/to/cmd --arg1 one
178+ proxy: "http://localhost:8080"
179+ aliases:
180+ - m1
181+ model2:
182+ cmd: path/to/cmd --arg1 one
183+ proxy: "http://localhost:8081"
184+ checkEndpoint: "/"
185+ aliases:
186+ - m1
187+ - m2
188+ `
182189
190+ // Load the config and verify
191+ _ , err := LoadConfigFromReader (strings .NewReader (content ))
192+ assert .Equal (t , "duplicate alias m1 found in model: model2" , err .Error ())
183193}
184194
185195func TestConfig_ModelConfigSanitizedCommand (t * testing.T ) {
0 commit comments