diff --git a/Tests/ApiTests/Resources/GeoLite2-ASN_20200526/COPYRIGHT.txt b/Tests/ApiTests/Resources/GeoLite2-ASN_20200526/COPYRIGHT.txt new file mode 100644 index 0000000..9c5395f --- /dev/null +++ b/Tests/ApiTests/Resources/GeoLite2-ASN_20200526/COPYRIGHT.txt @@ -0,0 +1 @@ +Database and Contents Copyright (c) 2020 MaxMind, Inc. diff --git a/Tests/ApiTests/Resources/GeoLite2-ASN_20200526/GeoLite2-ASN.mmdb b/Tests/ApiTests/Resources/GeoLite2-ASN_20200526/GeoLite2-ASN.mmdb new file mode 100644 index 0000000..702ee2c Binary files /dev/null and b/Tests/ApiTests/Resources/GeoLite2-ASN_20200526/GeoLite2-ASN.mmdb differ diff --git a/Tests/ApiTests/Resources/GeoLite2-ASN_20200526/LICENSE.txt b/Tests/ApiTests/Resources/GeoLite2-ASN_20200526/LICENSE.txt new file mode 100644 index 0000000..ee7434d --- /dev/null +++ b/Tests/ApiTests/Resources/GeoLite2-ASN_20200526/LICENSE.txt @@ -0,0 +1,3 @@ +Use of this MaxMind product is governed by MaxMind's GeoLite2 End User License Agreement, which can be viewed at https://www.maxmind.com/en/geolite2/eula. + +This database incorporates GeoNames [https://www.geonames.org] geographical data, which is made available under the Creative Commons Attribution 4.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/. diff --git a/Tests/ApiTests/Resources/GeoLite2-City_20200526/COPYRIGHT.txt b/Tests/ApiTests/Resources/GeoLite2-City_20200526/COPYRIGHT.txt new file mode 100644 index 0000000..9c5395f --- /dev/null +++ b/Tests/ApiTests/Resources/GeoLite2-City_20200526/COPYRIGHT.txt @@ -0,0 +1 @@ +Database and Contents Copyright (c) 2020 MaxMind, Inc. diff --git a/Tests/ApiTests/Resources/GeoLite2-City_20200526/GeoLite2-City.mmdb b/Tests/ApiTests/Resources/GeoLite2-City_20200526/GeoLite2-City.mmdb new file mode 100644 index 0000000..afcfc82 Binary files /dev/null and b/Tests/ApiTests/Resources/GeoLite2-City_20200526/GeoLite2-City.mmdb differ diff --git a/Tests/ApiTests/Resources/GeoLite2-City_20200526/LICENSE.txt b/Tests/ApiTests/Resources/GeoLite2-City_20200526/LICENSE.txt new file mode 100644 index 0000000..ee7434d --- /dev/null +++ b/Tests/ApiTests/Resources/GeoLite2-City_20200526/LICENSE.txt @@ -0,0 +1,3 @@ +Use of this MaxMind product is governed by MaxMind's GeoLite2 End User License Agreement, which can be viewed at https://www.maxmind.com/en/geolite2/eula. + +This database incorporates GeoNames [https://www.geonames.org] geographical data, which is made available under the Creative Commons Attribution 4.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/. diff --git a/Tests/ApiTests/Resources/GeoLite2-City_20200526/README.txt b/Tests/ApiTests/Resources/GeoLite2-City_20200526/README.txt new file mode 100644 index 0000000..16e29ad --- /dev/null +++ b/Tests/ApiTests/Resources/GeoLite2-City_20200526/README.txt @@ -0,0 +1 @@ +Latitude and longitude are not precise and should not be used to identify a particular street address or household. diff --git a/Tests/ApiTests/Resources/GeoLite2-Country_20200421/COPYRIGHT.txt b/Tests/ApiTests/Resources/GeoLite2-Country_20200421/COPYRIGHT.txt new file mode 100644 index 0000000..b494c35 --- /dev/null +++ b/Tests/ApiTests/Resources/GeoLite2-Country_20200421/COPYRIGHT.txt @@ -0,0 +1 @@ +Database and Contents Copyright (c) 2020 MaxMind, Inc. \ No newline at end of file diff --git a/Tests/ApiTests/Resources/GeoLite2-Country_20200421/GeoLite2-Country.mmdb b/Tests/ApiTests/Resources/GeoLite2-Country_20200421/GeoLite2-Country.mmdb new file mode 100644 index 0000000..7ed9ddc Binary files /dev/null and b/Tests/ApiTests/Resources/GeoLite2-Country_20200421/GeoLite2-Country.mmdb differ diff --git a/Tests/ApiTests/Resources/GeoLite2-Country_20200421/LICENSE.txt b/Tests/ApiTests/Resources/GeoLite2-Country_20200421/LICENSE.txt new file mode 100644 index 0000000..c528e38 --- /dev/null +++ b/Tests/ApiTests/Resources/GeoLite2-Country_20200421/LICENSE.txt @@ -0,0 +1,3 @@ +Use of this MaxMind product is governed by MaxMind's GeoLite2 End User License Agreement, which can be viewed at https://www.maxmind.com/en/geolite2/eula. + +This database incorporates GeoNames [https://www.geonames.org] geographical data, which is made available under the Creative Commons Attribution 4.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/. \ No newline at end of file diff --git a/Tests/ApiTests/XCTestCase.swift b/Tests/ApiTests/XCTestCase.swift index fb7199f..0a25655 100644 --- a/Tests/ApiTests/XCTestCase.swift +++ b/Tests/ApiTests/XCTestCase.swift @@ -3,18 +3,46 @@ import XCTest extension XCTestCase { - var bundle: Bundle { + static var bundle: Bundle { get { - guard let currentFileUrl = URL(string: #file) else { - return Bundle.main - } - + guard let currentFileUrl = URL(string: #file) else { return Bundle.main } guard let testBundle = Bundle(path: currentFileUrl.deletingLastPathComponent().path) else { return Bundle.main } - return testBundle } } + var bundle: Bundle { get { return XCTestCase.bundle } } + + private static var countryFilePath: String { + get { + guard let countryFilePath = bundle.path( + forResource: "GeoLite2-Country_20200421/GeoLite2-Country", + ofType: "mmdb" + ) else { fatalError("GeoLite2 Country DB file was not found.") } + return countryFilePath + } + } + + private static var cityFilePath: String { + get { + guard let countryFilePath = bundle.path( + forResource: "GeoLite2-City_20200526/GeoLite2-City", + ofType: "mmdb" + ) else { fatalError("GeoLite2 Country DB file was not found.") } + return countryFilePath + } + } + + private static var asnFilePath: String { + get { + guard let countryFilePath = bundle.path( + forResource: "GeoLite2-ASN_20200526/GeoLite2-ASN", + ofType: "mmdb" + ) else { fatalError("GeoLite2 Country DB file was not found.") } + return countryFilePath + } + } + }