Closed gerbyzation closed 6 years ago
Yeah, there's no elegant solution to this. What about adding TESTING=true
env var, and if present start_ckan_development.sh
would unset CKAN_SQLALCHEMY_URL
? Or something along those lines.
That would mean you can't run the dev server and tests in the same container though.
I've discovered env -i
, which allows you to run a command with a clean environment (env -i env
will print nothing). When running the tests with this it does use the test database, but raises on reset_db
. Will look further into this later
I've just been running the tests with a clean environment using env -i
(something like env -i nosetests --nologcapture --with-pylons=test.ini
), which works fine but is of course avoidance of the real problem. Any proper solution would have to happen in CKAN though I think, so I'll close this issue.
When starting in development the paster tool sets the database url in
test-core.ini
to the urls provided in the test environment variables.In my
test-core.ini
thesqlalchemy.url
is set topostgres://ckan:ckan@db/ckan_test
, but when checking the value in a test readspostgresql://ckan:ckan@db/ckan
. This must come from theCKAN_SQLALCHEMY_URL
which CKAN interprets itself as it's only provided in the.env
file.Besides modernising CKAN's config, I can only think of two solutions at the moment
ckanext-envvars
but keep the ENV vars with the same naming scheme (making sure they don't get picked up by CKAN itself) and write them to the config file with theconfig-tool
.Both seem sub-optimal to me, any thoughts?