Skip to content

Commit

Permalink
Individual update snapshot func (#561)
Browse files Browse the repository at this point in the history
* Add individual update snapshot functions

* Update tests

* Make private
  • Loading branch information
gnawf committed Jul 5, 2024
1 parent 596626d commit fe02676
Show file tree
Hide file tree
Showing 28 changed files with 129 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.squareup.kotlinpoet.AnnotationSpec
import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.CodeBlock
import com.squareup.kotlinpoet.FileSpec
import com.squareup.kotlinpoet.FunSpec
import com.squareup.kotlinpoet.KModifier
import com.squareup.kotlinpoet.MemberName
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
Expand All @@ -25,14 +26,25 @@ import kotlin.reflect.KClass
// For navigation so you can search up UpdateTestSnapshots
private typealias UpdateTestSnapshots = Unit

suspend fun main() {
suspend inline fun <reified T : NadelIntegrationTest> update() {
return update(T::class)
}

suspend fun <T : NadelIntegrationTest> update(klass: KClass<T>) {
main(klass.qualifiedName!!)
}

private suspend fun main(vararg args: String) {
val sourceRoot = File("test/src/test/kotlin/")
require(sourceRoot.exists() && sourceRoot.isDirectory)

getTestClassSequence()
.onEach { klass ->
println("Loading ${klass.qualifiedName}")
}
.filter {
args.isEmpty() || args.contains(it.qualifiedName)
}
.map {
it to it.newInstanceNoArgConstructor()
}
Expand All @@ -45,6 +57,7 @@ suspend fun main() {
val outputFile = FileSpec.builder(ClassName.bestGuess(klass.qualifiedName!! + "Snapshot"))
.indent(' '.toString().repeat(4))
.addFileComment("@formatter:off")
.addFunction(makeUpdateSnapshotFunction(klass))
.addType(makeTestSnapshotClass(klass, captured))
.build()
.writeTo(sourceRoot)
Expand All @@ -65,6 +78,13 @@ suspend fun main() {
}
}

fun makeUpdateSnapshotFunction(klass: KClass<NadelIntegrationTest>): FunSpec {
return FunSpec.builder("main")
.addModifiers(KModifier.PRIVATE, KModifier.SUSPEND)
.addCode("graphql.nadel.tests.next.update<%T>()", klass)
.build()
}

private fun getTestClassSequence(): Sequence<KClass<NadelIntegrationTest>> {
return ClassPath.from(ClassLoader.getSystemClassLoader())
.getTopLevelClassesRecursive("graphql.nadel.tests")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<BasicObjectSchemaTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<EchoTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<ComprehensiveDeferQueryWithDifferentServiceCalls>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<DeferOnListItemsTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<DeferThrowsErrorTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<DeferWithIfFalseTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<DeferWithLabelTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<DeferWithoutLabelTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<MultipleDeferDirectivesTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<MultipleDeferWithDifferentServiceCalls>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<MultipleFieldsinMultipleDeferDirectivesTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<MultipleFieldsinSingleDeferDirectiveTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<NestedDefersTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationDeferFlagOffTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationDeferInRenamedFieldAndNestedHydrationsTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationDeferInRenamedFieldTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationDeferInRenamedFieldUsingRenamedFieldTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationDeferIsDisabledForNestedHydrationsTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationDeferIsDisabledForRelatedIssuesTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationDeferIsDisabledInListOfRelatedIssuesForParentIssueTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationDeferIsDisabledTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<HydrationDeferTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<InstrumentationBeginExecuteOnCompleteOnFailureTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<InstrumentationBeginExecuteOnCompleteOnSuccessTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<InstrumentationBeginQueryExecutionOnCompleteOnFailureTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.listOf

private suspend fun main() {
graphql.nadel.tests.next.update<InstrumentationBeginQueryExecutionOnCompleteOnSuccessTest>()
}

/**
* This class is generated. Do NOT modify.
*
Expand Down

0 comments on commit fe02676

Please sign in to comment.