mirror of
https://github.com/Sosokker/site-to-llmstxt.git
synced 2025-12-18 21:44:06 +01:00
58 lines
987 B
Go
58 lines
987 B
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestConfig_Validate(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
config *Config
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "Valid config",
|
|
config: &Config{
|
|
URL: "https://example.com",
|
|
OutputDir: "./output",
|
|
Workers: 1,
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "Empty URL",
|
|
config: &Config{
|
|
URL: "",
|
|
OutputDir: "./output",
|
|
Workers: 1,
|
|
},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "Invalid URL",
|
|
config: &Config{
|
|
URL: "not-a-url",
|
|
OutputDir: "./output",
|
|
Workers: 1,
|
|
},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "Zero workers",
|
|
config: &Config{
|
|
URL: "https://example.com",
|
|
OutputDir: "./output",
|
|
Workers: 0,
|
|
},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
err := tt.config.Validate()
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("Config.Validate() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|