Created
January 31, 2023 15:56
-
-
Save adityadaniel/a1caccd0a6f0618c1211058c0ff6a7da to your computer and use it in GitHub Desktop.
Test Dependency TCA Sourcery Template
This file contains hidden or 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
{% for type in types.all where type.implements.DependencyKey %} | |
#if DEBUG | |
extension {{ type.name }}: TestDependencyKey { | |
{{ type.accessLevel }} static let testValue = {{ type.name }}( | |
{% for var in type.variables %} | |
{% if var.typeName.closure.actualReturnTypeName|contains:"Void"| %} | |
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: ()) | |
{% elif var.typeName.closure.actualReturnTypeName|contains:"Effect" %} | |
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: Effect.none) | |
{% elif var.typeName.closure.actualReturnTypeName.isArray %} | |
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: []) | |
{% elif var.typeName.closure.actualReturnTypeName.isOptional %} | |
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: nil) | |
{% elif var.typeName.closure.actualReturnTypeName|contains: "Double" %} | |
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: 0.00) | |
{% elif var.typeName.closure.actualReturnTypeName|contains: "String" %} | |
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: "") | |
{% elif var.typeName.closure.actualReturnTypeName|contains: "Int" %} | |
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: 0) | |
{% elif var.typeName.closure.actualReturnTypeName|contains: "Bool" %} | |
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: false) | |
{% else %} | |
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: {{ var.typeName.closure.actualReturnTypeName }}()) | |
{% endif %} | |
{% endfor %} | |
) | |
} | |
#endif | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment