config init now leaves out the test sources unless given --all
A section tagged init:"hidden" isn't written to the file config init generates; fts_mock and sleeper are. config init --all writes them too. They still load, and the config commands read and set them as before.
This commit is contained in:
1 parent
f467c6c7da
commit
b0f93fd437
8 files changed
+131
-21
No files matched your search
@@ -214,6 +214,32 @@ func TestConfigInit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The test sources are left out of the file unless --all is given.
|
||||
func TestConfigInitTestSources(t *testing.T) {
|
||||
cmdtest.Setup(t, "")
|
||||
|
||||
mustRun(t, "config", "init", "./default.yaml")
|
||||
written := cmdtest.ReadFile(t, "default.yaml")
|
||||
cmdtest.Contains(t, written, "find_a_tender:", "eu_supply:")
|
||||
for _, hidden := range []string{"fts_mock", "sleeper"} {
|
||||
if strings.Contains(written, hidden) {
|
||||
t.Errorf("init wrote %s without --all:\n%s", hidden, written)
|
||||
}
|
||||
}
|
||||
|
||||
mustRun(t, "config", "init", "--all", "./all.yaml")
|
||||
cmdtest.Contains(
|
||||
t, cmdtest.ReadFile(t, "all.yaml"), "fts_mock:", "sleeper:",
|
||||
)
|
||||
|
||||
// The test sources still load and are set as usual.
|
||||
mustRun(
|
||||
t, "--config", "default.yaml",
|
||||
"config", "set", "sources.sleeper.enabled", "true",
|
||||
)
|
||||
cmdtest.Contains(t, cmdtest.ReadFile(t, "default.yaml"), "sleeper:")
|
||||
}
|
||||
|
||||
// With no path (or a blank one), init searches the default locations. The
|
||||
// working directory is one, so its config.yaml is found. (Not finding one
|
||||
// would write to /etc/job-search, which a test can't do.)
|
||||
|
||||
Reference in new issue
Block a user