A Go config family per subject (parse / load / validate) and a README * section about the Mail one: enough for doc -> code candidates. */
| 15275 | /* A Go config family per subject (parse / load / validate) and a README |
| 15276 | * section about the Mail one: enough for doc -> code candidates. */ |
| 15277 | static void doccand_fixture(const char *repo) { |
| 15278 | static const char *const subjects[] = {"User", "Server", "Cache", "Mail"}; |
| 15279 | for (size_t i = 0; i < sizeof(subjects) / sizeof(subjects[0]); i++) { |
| 15280 | const char *s = subjects[i]; |
| 15281 | char path[512]; |
| 15282 | snprintf(path, sizeof(path), "%s/%s_config.go", repo, s); |
| 15283 | char body[2048]; |
| 15284 | snprintf(body, sizeof(body), |
| 15285 | "package main\n\n" |
| 15286 | "// Parse%sConfig reads the %s config file and returns the parsed %s config.\n" |
| 15287 | "func Parse%sConfig(path string) (*%sConfig, error) {\n" |
| 15288 | "\treturn Load%sConfig(path)\n}\n\n" |
| 15289 | "// Load%sConfig loads the %s config from disk and validates it.\n" |
| 15290 | "func Load%sConfig(path string) (*%sConfig, error) {\n" |
| 15291 | "\tcfg := &%sConfig{}\n\tValidate%sConfig(cfg)\n\treturn cfg, nil\n}\n\n" |
| 15292 | "// Validate%sConfig checks the %s config for missing fields.\n" |
| 15293 | "func Validate%sConfig(cfg *%sConfig) bool {\n\treturn cfg != nil\n}\n\n" |
| 15294 | "type %sConfig struct{ Name string }\n", |
| 15295 | s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s, s); |
| 15296 | th_write_file(path, body); |
| 15297 | } |
| 15298 | char readme[512]; |
| 15299 | snprintf(readme, sizeof(readme), "%s/README.md", repo); |
| 15300 | th_write_file(readme, "# Mail configuration\n\n" |
| 15301 | "The mail config file is parsed by ParseMailConfig, which loads the mail " |
| 15302 | "config from disk and validates the mail config fields before anything " |
| 15303 | "reads them. Missing fields fail the validation, and the parsed mail " |
| 15304 | "config can be written back to disk afterwards.\n"); |
| 15305 | } |
| 15306 | |
| 15307 | /* The one project DB in a private cache (not _config.db or activity.db), so |
| 15308 | * the test does not depend on how the server canonicalized the repo path. */ |
no test coverage detected