Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💚 Fix Tests #69

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ class ActionMappingSymbolProcessor(
}
}

private fun KSClassDeclaration.actionMappingFileBuilder() =
FileSpec.builder(
packageName = packageName.getQualifier(),
fileName = "${toClassName().simpleName}ActionMappings",
private fun KSClassDeclaration.actionMappingFileBuilder(): FileSpec.Builder {
val className = toClassName()

return FileSpec.builder(
packageName = className.packageName,
fileName = "${className.simpleName}ActionMappings",
)
}
}

class ActionMappingSymbolProcessorProvider : SymbolProcessorProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ActionMappingSymbolProcessorTests {

val sources = result.kspGeneratedSources()
sources.size.shouldBe(1)
sources.single().readText().contentEquals(SourceFiles.generatedSettingsFile)
sources.single().readText().shouldBe(SourceFiles.generatedActionExtensionsFile)
}

@Test
Expand All @@ -44,7 +44,7 @@ class ActionMappingSymbolProcessorTests {

val sources = result.kspGeneratedSources()
sources.size.shouldBe(1)
sources.single().readText().contentEquals(SourceFiles.generatedSettingsFileWithoutPackage)
sources.single().readText().shouldBe(SourceFiles.generatedActionExtensionsFileWithoutPackage)
}

@Test
Expand Down
31 changes: 15 additions & 16 deletions komposable-architecture-compiler/src/test/kotlin/SourceFiles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object SourceFiles {
val settingsAction = SourceFile.kotlin(
"SettingsAction.kt",
"""
package com.toggl.komposable.compiler.testing
package com.toggl.komposable.compiler

sealed interface SettingsAction {
data class ChangeSomeSetting(val newValue: Boolean) : SettingsAction
Expand All @@ -26,7 +26,7 @@ object SourceFiles {
val appAction = SourceFile.kotlin(
"AppAction.kt",
"""
package com.toggl.komposable.compiler.testing
package com.toggl.komposable.compiler

import com.toggl.komposable.architecture.WrapperAction

Expand Down Expand Up @@ -56,7 +56,7 @@ object SourceFiles {
val appActionWithMultipleProperties = SourceFile.kotlin(
"AppAction.kt",
"""
package com.toggl.komposable.compiler.testing
package com.toggl.komposable.compiler

import com.toggl.komposable.architecture.WrapperAction

Expand All @@ -70,25 +70,24 @@ object SourceFiles {
)

@Language("kotlin")
val generatedSettingsFile = """
package com.toggl.komposable.compiler.testing

import AppAction.Settings

public fun mapAppActionToSettingsAction(appAction: AppAction): SettingsAction? = if(appAction is
AppAction.Settings) appAction.settingsAction else null

public fun mapSettingsActionToAppAction(settingsAction: SettingsAction): AppAction.Settings =
AppAction.Settings(settingsAction)
""".trimIndent()
val generatedActionExtensionsFile = """package com.toggl.komposable.compiler

import com.toggl.komposable.compiler.AppAction.Settings

public fun mapAppActionToSettingsAction(appAction: AppAction): SettingsAction? = if(appAction is
AppAction.Settings) appAction.settingsAction else null

public fun mapSettingsActionToAppAction(settingsAction: SettingsAction): AppAction.Settings =
AppAction.Settings(settingsAction)
"""

@Language("kotlin")
val generatedSettingsFileWithoutPackage = """import AppAction.Settings
val generatedActionExtensionsFileWithoutPackage = """import AppAction.Settings

public fun mapAppActionToSettingsAction(appAction: AppAction): SettingsAction? = if(appAction is
AppAction.Settings) appAction.settingsAction else null

public fun mapSettingsActionToAppAction(settingsAction: SettingsAction): AppAction.Settings =
AppAction.Settings(settingsAction)
""".trimIndent()
"""
}