-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2896278
commit 0b69e2d
Showing
3 changed files
with
48 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,53 @@ | ||
# pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned,singleton-comparison | ||
|
||
import os | ||
from contextlib import contextmanager | ||
|
||
from expecter import expect | ||
|
||
from envdiff import utils | ||
|
||
|
||
@contextmanager | ||
def inside(dirpath): | ||
cwd = os.getcwd() | ||
os.chdir(dirpath) | ||
try: | ||
yield | ||
finally: | ||
os.chdir(cwd) | ||
|
||
|
||
def describe_init_config(): | ||
|
||
def it_sets_sample_data(tmpdir): | ||
tmpdir.chdir() | ||
|
||
config, created = utils.init_config() | ||
|
||
expect(created) == True | ||
expect(config.__mapper__.data) == dict( | ||
sourcefiles=[ | ||
dict(path="app.json"), | ||
dict(path=".env"), | ||
], | ||
environments=[ | ||
dict(name="localhost", command="env"), | ||
dict(name="production", command="heroku run env"), | ||
], | ||
) | ||
with inside(str(tmpdir)): | ||
|
||
config, created = utils.init_config() | ||
|
||
expect(created) == True | ||
expect(config.__mapper__.data) == dict( | ||
sourcefiles=[ | ||
dict(path="app.json"), | ||
dict(path=".env"), | ||
], | ||
environments=[ | ||
dict(name="localhost", command="env"), | ||
dict(name="production", command="heroku run env"), | ||
], | ||
) | ||
|
||
def it_leaves_existing_files_alone(tmpdir): | ||
tmpdir.chdir() | ||
with open("env-diff.yml", 'w') as config_text: | ||
config_text.write("sourcefiles: [{path: 'foo.bar'}]") | ||
|
||
config, created = utils.init_config() | ||
|
||
expect(created) == False | ||
expect(config.__mapper__.data) == dict( | ||
sourcefiles=[ | ||
dict(path="foo.bar"), | ||
], | ||
) | ||
with inside(str(tmpdir)): | ||
|
||
with open("env-diff.yml", 'w') as config_text: | ||
config_text.write("sourcefiles: [{path: 'foo.bar'}]") | ||
|
||
config, created = utils.init_config() | ||
|
||
expect(created) == False | ||
expect(config.__mapper__.data) == dict( | ||
sourcefiles=[ | ||
dict(path="foo.bar"), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters