Skip to content

Commit

Permalink
test: add test for package with only configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
artemrys authored and Artem Rys committed Aug 9, 2021
1 parent 5b6073d commit a5c3c3e
Show file tree
Hide file tree
Showing 36 changed files with 8,141 additions and 1 deletion.
429 changes: 429 additions & 0 deletions tests/data/package_global_config_configuration/globalConfig.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Just a readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"schemaVersion": "2.0.0",
"info": {
"title": "Splunk Add-on for UCC Example",
"id": {
"group": null,
"name": "Splunk_TA_UCCExample",
"version": "7.0.1"
},
"author": [
{
"name": "Splunk",
"email": null,
"company": null
}
],
"releaseDate": null,
"description": "Splunk Add-on for UCC Example",
"classification": {
"intendedAudience": null,
"categories": [],
"developmentStatus": null
},
"commonInformationModels": null,
"license": {
"name": null,
"text": "LICENSES/Apache-2.0.txt",
"uri": null
},
"privacyPolicy": {
"name": null,
"text": null,
"uri": null
},
"releaseNotes": {
"name": null,
"text": "./README.txt",
"uri": null
}
},
"dependencies": null,
"tasks": null,
"inputGroups": null,
"incompatibleApps": null,
"platformRequirements": null,
"supportedDeployments": [
"_standalone",
"_distributed"
],
"targetWorkloads": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
######################################################
#
# ${package.name}
#
# ${copyright}
#
######################################################

[install]
build = 0

[launcher]
author = Splunk Inc.
version = 0.1.0
description = Splunk_TA_UCCExample

[ui]
is_visible = true
label = Splunk_TA_UCCExample
docs_section_override=AddOns:released

[package]
id = Splunk_TA_UCCExample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
splunktaucclib
49 changes: 48 additions & 1 deletion tests/data/test_ucc_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_ucc_generate(self):
)
ucc.generate(source=package_folder)

def test_ucc_generate_with_custom_output_folder(self):
def test_ucc_generate_with_inputs_configuration_alerts(self):
with tempfile.TemporaryDirectory() as temp_dir:
package_folder = path.join(
path.dirname(path.realpath(__file__)),
Expand Down Expand Up @@ -75,6 +75,53 @@ def test_ucc_generate_with_custom_output_folder(self):
msg=f"Expected file {expected_file_path} is different from {actual_file_path}",
)

def test_ucc_generate_with_configuration(self):
with tempfile.TemporaryDirectory() as temp_dir:
package_folder = path.join(
path.dirname(path.realpath(__file__)),
"package_global_config_configuration",
"package",
)
ucc.generate(source=package_folder, outputdir=temp_dir)

expected_folder = path.join(
path.dirname(__file__),
"..",
"expected_output_global_config_configuration",
"Splunk_TA_UCCExample",
)
actual_folder = path.join(temp_dir, "Splunk_TA_UCCExample")

# app.manifest and appserver/static/js/build/globalConfig.json
# should be included too, but they may introduce flaky tests as
# their content depends on the git commit.
# Expected add-on package folder does not have "lib" in it.
files_to_be_equal = [
("README.txt",),
("default", "restmap.conf"),
("default", "splunk_ta_uccexample_settings.conf"),
("default", "web.conf"),
("default", "data", "ui", "nav", "default.xml"),
("default", "data", "ui", "views", "configuration.xml"),
("default", "data", "ui", "views", "splunk_ta_uccexample_redirect.xml"),
("bin", "import_declare_test.py"),
("bin", "splunk_ta_uccexample_rh_account.py"),
("bin", "splunk_ta_uccexample_rh_oauth.py"),
("bin", "splunk_ta_uccexample_rh_settings.py"),
("README", "splunk_ta_uccexample_account.conf.spec"),
("README", "splunk_ta_uccexample_settings.conf.spec"),
]
for f in files_to_be_equal:
expected_file_path = path.join(expected_folder, *f)
actual_file_path = path.join(actual_folder, *f)
self.assertTrue(
assert_identical_files(
expected_file_path,
actual_file_path,
),
msg=f"Expected file {expected_file_path} is different from {actual_file_path}",
)


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Just a readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[<name>]
custom_endpoint =
endpoint =
account_checkbox =
account_radio =
account_multiple_select =
example_help_link =
username =
password =
token =
client_id =
client_secret =
redirect_url =
access_token =
refresh_token =
instance_url =
auth_type =
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[proxy]
proxy_enabled =
proxy_type =
proxy_url =
proxy_port =
proxy_username =
proxy_password =
proxy_rdns =

[logging]
loglevel =

[custom_abc]
testString =
testNumber =
testRegex =
testEmail =
testIpv4 =
testDate =
testUrl =
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.0.0
1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"dependencies": null,
"incompatibleApps": null,
"info": {
"author": [
{
"company": null,
"email": null,
"name": "Splunk"
}
],
"classification": {
"categories": [],
"developmentStatus": null,
"intendedAudience": null
},
"commonInformationModels": null,
"description": "Splunk Add-on for UCC Example",
"id": {
"group": null,
"name": "Splunk_TA_UCCExample",
"version": "1.0.0"
},
"license": {
"name": null,
"text": "LICENSES/Apache-2.0.txt",
"uri": null
},
"privacyPolicy": {
"name": null,
"text": null,
"uri": null
},
"releaseDate": null,
"releaseNotes": {
"name": null,
"text": "./README.txt",
"uri": null
},
"title": "Splunk Add-on for UCC Example"
},
"inputGroups": null,
"platformRequirements": null,
"schemaVersion": "2.0.0",
"supportedDeployments": [
"_standalone",
"_distributed"
],
"targetWorkloads": null,
"tasks": null
}

Large diffs are not rendered by default.

Loading

0 comments on commit a5c3c3e

Please sign in to comment.