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

Function TestProjectConfigFile

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

Source from the content-addressed store, hash-verified

83}
84
85func TestProjectConfigFile(t *testing.T) {
86 tempDir := t.TempDir()
87
88 // Create a project structure
89 projectDir := filepath.Join(tempDir, "myproject")
90 asterDir := filepath.Join(projectDir, ".aster")
91 subDir := filepath.Join(projectDir, "src", "components")
92
93 if err := os.MkdirAll(asterDir, 0755); err != nil {
94 t.Fatal(err)
95 }
96 if err := os.MkdirAll(subDir, 0755); err != nil {
97 t.Fatal(err)
98 }
99
100 // Create config file
101 configFile := filepath.Join(asterDir, "config.yaml")
102 if err := os.WriteFile(configFile, []byte("test: true"), 0644); err != nil {
103 t.Fatal(err)
104 }
105
106 // Test from subdirectory
107 found := ProjectConfigFile(subDir)
108 if found != configFile {
109 t.Errorf("Expected %s, got %s", configFile, found)
110 }
111
112 // Test from project root
113 found = ProjectConfigFile(projectDir)
114 if found != configFile {
115 t.Errorf("Expected %s, got %s", configFile, found)
116 }
117
118 // Test from directory without config
119 found = ProjectConfigFile(tempDir)
120 if found != "" {
121 t.Errorf("Expected empty string, got %s", found)
122 }
123}
124
125func TestResolveConfigFile(t *testing.T) {
126 pathsOnce = sync.Once{}

Callers

nothing calls this directly

Calls 2

ProjectConfigFileFunction · 0.85
JoinMethod · 0.45

Tested by

no test coverage detected