MCPcopy Create free account
hub / github.com/astercloud/aster / TestResolveConfigFile

Function TestResolveConfigFile

pkg/config/paths_test.go:125–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

123}
124
125func TestResolveConfigFile(t *testing.T) {
126 pathsOnce = sync.Once{}
127 tempDir := t.TempDir()
128
129 // Without project config, should return global
130 resolved := ResolveConfigFile(tempDir)
131 if resolved != ConfigFile() {
132 t.Errorf("Expected global config, got %s", resolved)
133 }
134
135 // With project config
136 projectDir := filepath.Join(tempDir, "myproject")
137 asterDir := filepath.Join(projectDir, ".aster")
138 if err := os.MkdirAll(asterDir, 0755); err != nil {
139 t.Fatal(err)
140 }
141
142 configFile := filepath.Join(asterDir, "config.yaml")
143 if err := os.WriteFile(configFile, []byte("test: true"), 0644); err != nil {
144 t.Fatal(err)
145 }
146
147 resolved = ResolveConfigFile(projectDir)
148 if resolved != configFile {
149 t.Errorf("Expected project config %s, got %s", configFile, resolved)
150 }
151}
152
153func contains(s, substr string) bool {
154 return len(s) >= len(substr) && (s == substr || len(s) > 0 && containsImpl(s, substr))

Callers

nothing calls this directly

Calls 3

ResolveConfigFileFunction · 0.85
ConfigFileFunction · 0.85
JoinMethod · 0.45

Tested by

no test coverage detected