Add visibility parameters to control scope of generated extension
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
@ -0,0 +1,76 @@
|
||||
//
|
||||
// AnalyticsConfigurationTests.swift
|
||||
// ResgenSwift
|
||||
//
|
||||
// Created by Thibaut Schmitt on 18/07/2025.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@testable import ResgenSwift
|
||||
import XCTest
|
||||
|
||||
final class AnalyticsConfigurationTests: XCTestCase {
|
||||
|
||||
let projectDirectory = "projectDirectory/"
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = AnalyticsConfiguration(
|
||||
inputFile: "path/to/tags.yml",
|
||||
target: "matomo firebase",
|
||||
outputFile: "Analytics/Generated/AnalyticsManager.swift",
|
||||
visibility: nil,
|
||||
staticMembers: nil
|
||||
)
|
||||
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: false
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
"projectDirectory/path/to/tags.yml",
|
||||
"--target",
|
||||
"matomo firebase",
|
||||
"--output-file",
|
||||
"projectDirectory/Analytics/Generated/AnalyticsManager.swift",
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
}
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = AnalyticsConfiguration(
|
||||
inputFile: "path/to/tags.yml",
|
||||
target: "matomo firebase",
|
||||
outputFile: "Analytics/Generated/AnalyticsManager.swift",
|
||||
visibility: "public",
|
||||
staticMembers: false
|
||||
)
|
||||
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: true
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
"-f",
|
||||
"projectDirectory/path/to/tags.yml",
|
||||
"--target",
|
||||
"matomo firebase",
|
||||
"--output-file",
|
||||
"projectDirectory/Analytics/Generated/AnalyticsManager.swift",
|
||||
"--visibility",
|
||||
"public",
|
||||
"--static-members",
|
||||
"false"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
}
|
||||
}
|
@ -16,16 +16,22 @@ final class ColorsConfigurationTests: XCTestCase {
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt",
|
||||
style: ColorStyle.all.rawValue,
|
||||
xcassetsPath: "path/to/assets.xcassets",
|
||||
extensionOutputPath: nil,
|
||||
extensionName: nil,
|
||||
extensionNameUIKit: nil,
|
||||
extensionSuffix: nil,
|
||||
staticMembers: false)
|
||||
let testingConfiguration = ColorsConfiguration(
|
||||
inputFile: "path/to/colors.txt",
|
||||
style: ColorStyle.all.rawValue,
|
||||
xcassetsPath: "path/to/assets.xcassets",
|
||||
extensionOutputPath: nil,
|
||||
extensionName: nil,
|
||||
extensionNameUIKit: nil,
|
||||
extensionSuffix: nil,
|
||||
visibility: nil,
|
||||
staticMembers: false
|
||||
)
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: false
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
@ -43,16 +49,22 @@ final class ColorsConfigurationTests: XCTestCase {
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt",
|
||||
style: ColorStyle.all.rawValue,
|
||||
xcassetsPath: "path/to/assets.xcassets",
|
||||
extensionOutputPath: "Colors/Generated",
|
||||
extensionName: "AppUIColor",
|
||||
extensionNameUIKit: "AppColor",
|
||||
extensionSuffix: "Testing",
|
||||
staticMembers: false)
|
||||
let testingConfiguration = ColorsConfiguration(
|
||||
inputFile: "path/to/colors.txt",
|
||||
style: ColorStyle.all.rawValue,
|
||||
xcassetsPath: "path/to/assets.xcassets",
|
||||
extensionOutputPath: "Colors/Generated",
|
||||
extensionName: "AppUIColor",
|
||||
extensionNameUIKit: "AppColor",
|
||||
extensionSuffix: "Testing",
|
||||
visibility: "public",
|
||||
staticMembers: false
|
||||
)
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: true
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
@ -62,8 +74,6 @@ final class ColorsConfigurationTests: XCTestCase {
|
||||
"all",
|
||||
"--xcassets-path",
|
||||
"projectDirectory/path/to/assets.xcassets",
|
||||
"--static-members",
|
||||
"false",
|
||||
"--extension-output-path",
|
||||
"projectDirectory/Colors/Generated",
|
||||
"--extension-name",
|
||||
@ -72,6 +82,10 @@ final class ColorsConfigurationTests: XCTestCase {
|
||||
"AppColor",
|
||||
"--extension-suffix",
|
||||
"Testing",
|
||||
"--visibility",
|
||||
"public",
|
||||
"--static-members",
|
||||
"false"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
|
@ -16,21 +16,25 @@ final class FontsConfigurationTests: XCTestCase {
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
|
||||
extensionOutputPath: nil,
|
||||
extensionName: nil,
|
||||
extensionNameUIKit: nil,
|
||||
extensionSuffix: nil,
|
||||
infoPlistPaths: nil,
|
||||
staticMembers: nil)
|
||||
let testingConfiguration = FontsConfiguration(
|
||||
inputFile: "path/to/fonts.txt",
|
||||
extensionOutputPath: nil,
|
||||
extensionName: nil,
|
||||
extensionNameUIKit: nil,
|
||||
extensionSuffix: nil,
|
||||
infoPlistPaths: nil,
|
||||
visibility: nil,
|
||||
staticMembers: nil
|
||||
)
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: false
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
"projectDirectory/path/to/fonts.txt",
|
||||
"--static-members",
|
||||
"false"
|
||||
"projectDirectory/path/to/fonts.txt"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
@ -38,22 +42,26 @@ final class FontsConfigurationTests: XCTestCase {
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
|
||||
extensionOutputPath: "Fonts/Generated",
|
||||
extensionName: "AppUIFont",
|
||||
extensionNameUIKit: "AppFont",
|
||||
extensionSuffix: "Testing",
|
||||
infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist",
|
||||
staticMembers: true)
|
||||
let testingConfiguration = FontsConfiguration(
|
||||
inputFile: "path/to/fonts.txt",
|
||||
extensionOutputPath: "Fonts/Generated",
|
||||
extensionName: "AppUIFont",
|
||||
extensionNameUIKit: "AppFont",
|
||||
extensionSuffix: "Testing",
|
||||
infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist",
|
||||
visibility: "package",
|
||||
staticMembers: true
|
||||
)
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: true
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
"-f",
|
||||
"projectDirectory/path/to/fonts.txt",
|
||||
"--static-members",
|
||||
"true",
|
||||
"--extension-output-path",
|
||||
"projectDirectory/Fonts/Generated",
|
||||
"--extension-name",
|
||||
@ -62,6 +70,10 @@ final class FontsConfigurationTests: XCTestCase {
|
||||
"AppFont",
|
||||
"--extension-suffix",
|
||||
"Testing",
|
||||
"--visibility",
|
||||
"package",
|
||||
"--static-members",
|
||||
"true",
|
||||
"--info-plist-paths",
|
||||
"projectDirectory/path/to/plist1.plist projectDirectory/path/to/plist2.plist"
|
||||
]
|
||||
|
@ -16,24 +16,28 @@ final class ImagesConfigurationTests: XCTestCase {
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt",
|
||||
xcassetsPath: "path/to/assets.xcassets",
|
||||
extensionOutputPath: nil,
|
||||
extensionName: nil,
|
||||
extensionNameUIKit: nil,
|
||||
extensionSuffix: nil,
|
||||
staticMembers: nil)
|
||||
let testingConfiguration = ImagesConfiguration(
|
||||
inputFile: "path/to/images.txt",
|
||||
xcassetsPath: "path/to/assets.xcassets",
|
||||
extensionOutputPath: nil,
|
||||
extensionName: nil,
|
||||
extensionNameUIKit: nil,
|
||||
extensionSuffix: nil,
|
||||
visibility: nil,
|
||||
staticMembers: nil
|
||||
)
|
||||
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: false
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
"projectDirectory/path/to/images.txt",
|
||||
"--xcassets-path",
|
||||
"projectDirectory/path/to/assets.xcassets",
|
||||
"--static-members",
|
||||
"false"
|
||||
"projectDirectory/path/to/assets.xcassets"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
@ -41,16 +45,22 @@ final class ImagesConfigurationTests: XCTestCase {
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt",
|
||||
xcassetsPath: "path/to/assets.xcassets",
|
||||
extensionOutputPath: "Images/Generated",
|
||||
extensionName: "AppUIImage",
|
||||
extensionNameUIKit: "AppImage",
|
||||
extensionSuffix: "Testing",
|
||||
staticMembers: true)
|
||||
let testingConfiguration = ImagesConfiguration(
|
||||
inputFile: "path/to/images.txt",
|
||||
xcassetsPath: "path/to/assets.xcassets",
|
||||
extensionOutputPath: "Images/Generated",
|
||||
extensionName: "AppUIImage",
|
||||
extensionNameUIKit: "AppImage",
|
||||
extensionSuffix: "Testing",
|
||||
visibility: "private",
|
||||
staticMembers: true
|
||||
)
|
||||
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: true
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
@ -58,8 +68,6 @@ final class ImagesConfigurationTests: XCTestCase {
|
||||
"projectDirectory/path/to/images.txt",
|
||||
"--xcassets-path",
|
||||
"projectDirectory/path/to/assets.xcassets",
|
||||
"--static-members",
|
||||
"true",
|
||||
"--extension-output-path",
|
||||
"projectDirectory/Images/Generated",
|
||||
"--extension-name",
|
||||
@ -68,6 +76,10 @@ final class ImagesConfigurationTests: XCTestCase {
|
||||
"AppImage",
|
||||
"--extension-suffix",
|
||||
"Testing",
|
||||
"--visibility",
|
||||
"private",
|
||||
"--static-members",
|
||||
"true"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
|
@ -0,0 +1,98 @@
|
||||
//
|
||||
// StringsConfigurationTests.swift
|
||||
// ResgenSwift
|
||||
//
|
||||
// Created by Thibaut Schmitt on 18/07/2025.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@testable import ResgenSwift
|
||||
import XCTest
|
||||
|
||||
final class StringsConfigurationTests: XCTestCase {
|
||||
|
||||
let projectDirectory = "projectDirectory/"
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = StringsConfiguration(
|
||||
inputFile: "path/to/strings.txt",
|
||||
outputPath: "Strings/Generated",
|
||||
langs: "fr en en-us",
|
||||
defaultLang: "en",
|
||||
extensionOutputPath: nil, // Strings/Generated
|
||||
extensionName: nil, // String
|
||||
extensionSuffix: nil, // Testing
|
||||
visibility: nil, // "internal"
|
||||
staticMembers: nil, // true
|
||||
xcStrings: nil // true
|
||||
)
|
||||
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: false
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
"projectDirectory/path/to/strings.txt",
|
||||
"--output-path",
|
||||
"projectDirectory/Strings/Generated",
|
||||
"--langs",
|
||||
"fr en en-us",
|
||||
"--default-lang",
|
||||
"en"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
}
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = StringsConfiguration(
|
||||
inputFile: "path/to/strings.txt",
|
||||
outputPath: "Strings/Generated",
|
||||
langs: "fr en en-us",
|
||||
defaultLang: "en",
|
||||
extensionOutputPath: "Strings/Generated",
|
||||
extensionName: "AppString",
|
||||
extensionSuffix: "Testing",
|
||||
visibility: "internal",
|
||||
staticMembers: true,
|
||||
xcStrings: true
|
||||
)
|
||||
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: true
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
"-f",
|
||||
"projectDirectory/path/to/strings.txt",
|
||||
"--output-path",
|
||||
"projectDirectory/Strings/Generated",
|
||||
"--langs",
|
||||
"fr en en-us",
|
||||
"--default-lang",
|
||||
"en",
|
||||
"--extension-output-path",
|
||||
"projectDirectory/Strings/Generated",
|
||||
"--extension-name",
|
||||
"AppString",
|
||||
"--extension-suffix",
|
||||
"Testing",
|
||||
"--visibility",
|
||||
"internal",
|
||||
"--xc-strings",
|
||||
"true",
|
||||
"--static-members",
|
||||
"true"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
}
|
||||
}
|
84
Tests/ResgenSwiftTests/Generate/TagsConfigurationTests.swift
Normal file
84
Tests/ResgenSwiftTests/Generate/TagsConfigurationTests.swift
Normal file
@ -0,0 +1,84 @@
|
||||
//
|
||||
// TagsConfigurationTests.swift
|
||||
// ResgenSwift
|
||||
//
|
||||
// Created by Thibaut Schmitt on 18/07/2025.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@testable import ResgenSwift
|
||||
import XCTest
|
||||
|
||||
final class TagsConfigurationTests: XCTestCase {
|
||||
|
||||
let projectDirectory = "projectDirectory/"
|
||||
|
||||
func test_argsGeneration_requiredArgs() {
|
||||
// Given
|
||||
let testingConfiguration = TagsConfiguration(
|
||||
inputFile: "path/to/tags.txt",
|
||||
lang: "ium",
|
||||
extensionOutputPath: "Tags/Generated",
|
||||
extensionName: nil,
|
||||
extensionSuffix: nil,
|
||||
visibility: nil,
|
||||
staticMembers: nil
|
||||
)
|
||||
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: false
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
"projectDirectory/path/to/tags.txt",
|
||||
"--lang",
|
||||
"ium",
|
||||
"--extension-output-path",
|
||||
"projectDirectory/Tags/Generated"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
}
|
||||
|
||||
func test_argsGeneration_allArguments() {
|
||||
// Given
|
||||
let testingConfiguration = TagsConfiguration(
|
||||
inputFile: "path/to/tags.txt",
|
||||
lang: "ium",
|
||||
extensionOutputPath: "Tags/Generated",
|
||||
extensionName: "AppTag",
|
||||
extensionSuffix: "Testing",
|
||||
visibility: "private",
|
||||
staticMembers: true
|
||||
)
|
||||
|
||||
// When
|
||||
let arguments = testingConfiguration.getArguments(
|
||||
projectDirectory: projectDirectory,
|
||||
force: true
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expectedArguments = [
|
||||
"-f",
|
||||
"projectDirectory/path/to/tags.txt",
|
||||
"--lang",
|
||||
"ium",
|
||||
"--extension-output-path",
|
||||
"projectDirectory/Tags/Generated",
|
||||
"--extension-name",
|
||||
"AppTag",
|
||||
"--extension-suffix",
|
||||
"Testing",
|
||||
"--visibility",
|
||||
"private",
|
||||
"--static-members",
|
||||
"true"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user