-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
CFE-3803 Modified cfbs add folder behavior
- Loading branch information
Showing
13 changed files
with
177 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,7 @@ node_modules/ | |
build/ | ||
dist/ | ||
.cache | ||
|
||
# Test Outputs | ||
test/add_folder_sample/cfbs.json | ||
test/add_folder_sample/out |
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
bundle agent bazbiz | ||
{ | ||
meta: | ||
"tags" slist => { "autorun" }; | ||
reports: "I am bazbiz."; | ||
} |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"vars": { | ||
"bazbizthing": "superlative" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"vars": { | ||
"foo_thing": "awesome" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
bundle agent foo | ||
{ | ||
meta: | ||
"tags" slist => { "autorun" }; | ||
reports: "I am foo."; | ||
} |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import os | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def chdir(request): | ||
os.chdir(os.path.join(os.path.dirname(__file__), request.param)) | ||
yield | ||
os.chdir(request.config.invocation_dir) |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import json | ||
import os | ||
import pytest | ||
from cfbs.commands import ( | ||
build_command, | ||
init_command, | ||
add_command, | ||
) | ||
from cfbs.utils import read_json | ||
|
||
|
||
@pytest.mark.parametrize("chdir", ["add_folder_sample"], indirect=True) | ||
def test_add_folders_and_build(chdir): | ||
os.system("rm -rf out") | ||
os.system("rm -f cfbs.json") | ||
init_command() | ||
add_command(["masterfiles"]) | ||
add_command(["./foo/"]) | ||
add_command(["./bar/"]) | ||
add_command(["./baz/"]) | ||
build_command() | ||
|
||
expected = json.loads( | ||
"""{ | ||
"classes": { "services_autorun_bundles": ["any"] }, | ||
"vars": { "foo_thing": "awesome", "bazbizthing": "superlative" }, | ||
"inputs": ["services/cfbs/foo/foo.cf", "services/cfbs/baz/bazbiz.cf"] | ||
}""" | ||
) | ||
actual = read_json("out/masterfiles/def.json") | ||
assert actual == expected | ||
|
||
actual = [] | ||
for root, dirs, files in os.walk("out/masterfiles/services/cfbs"): | ||
for dir in dirs: | ||
actual.append(os.path.join(root, dir)) | ||
for file in files: | ||
actual.append(os.path.join(root, file)) | ||
# sort these, different orders on different systems | ||
actual = sorted(actual) | ||
expected = [ | ||
"out/masterfiles/services/cfbs/bar", | ||
"out/masterfiles/services/cfbs/bar/bar.json", | ||
"out/masterfiles/services/cfbs/baz", | ||
"out/masterfiles/services/cfbs/baz/bazbiz.cf", | ||
"out/masterfiles/services/cfbs/baz/bazbiz.json", | ||
"out/masterfiles/services/cfbs/foo", | ||
"out/masterfiles/services/cfbs/foo/foo.cf", | ||
"out/masterfiles/services/cfbs/foo/oddfile.txt", | ||
] | ||
assert actual == expected |
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