From 15fe844d1dfb3689629af0c16f1a6e3b875e6145 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Thu, 4 Jan 2024 18:03:14 +0800 Subject: [PATCH] test: fix picker error NodeName issue --- .../pick/builder/unittest/rust/RustTestCodeService.kt | 8 ++++---- .../pick/builder/unittest/rust/RustTestCodeServiceTest.kt | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/unittest/rust/RustTestCodeService.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/unittest/rust/RustTestCodeService.kt index df8210b..67f7dfb 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/unittest/rust/RustTestCodeService.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/unittest/rust/RustTestCodeService.kt @@ -33,7 +33,7 @@ class RustTestCodeService(val job: JobContext) : UnitTestService { val result = testCode.map { codeFunction -> codeFunction.FunctionCalls.mapNotNull { codeCall -> - val canonicalName = buildCanonicalName(codeCall.NodeName, codeCall.FunctionName) + val canonicalName = buildCanonicalName(codeCall.Package, codeCall.FunctionName) val underTestFunction = functionMap.firstNotNullOfOrNull { it[canonicalName] } if (underTestFunction == null) { null @@ -65,9 +65,9 @@ class RustTestCodeService(val job: JobContext) : UnitTestService { return buildCanonicalName(function.Package, function.Name) } - private fun buildCanonicalName(nodeName: String, funcName: String): String { - val node = nodeName.ifEmpty { "main" } - return "$node::$funcName" + private fun buildCanonicalName(pkgName: String, funcName: String): String { + val pkg = pkgName.ifEmpty { "main" } + return "$pkg::$funcName" } override fun build(dataStruct: CodeDataStruct): List { diff --git a/unit-picker/src/test/kotlin/cc/unitmesh/pick/builder/unittest/rust/RustTestCodeServiceTest.kt b/unit-picker/src/test/kotlin/cc/unitmesh/pick/builder/unittest/rust/RustTestCodeServiceTest.kt index 41f8cbc..7389ca2 100644 --- a/unit-picker/src/test/kotlin/cc/unitmesh/pick/builder/unittest/rust/RustTestCodeServiceTest.kt +++ b/unit-picker/src/test/kotlin/cc/unitmesh/pick/builder/unittest/rust/RustTestCodeServiceTest.kt @@ -44,7 +44,7 @@ class RustTestCodeServiceTest { assert_eq!(embedding.len(), 128); } } - """.trimIndent() + """.trimIndent() val container = RustAnalyser().analysis(testCode, "lib.rs") container.buildSourceCode(testCode.lines()) @@ -70,7 +70,8 @@ class RustTestCodeServiceTest { val build: List = rustTestCodeService.build(container) as List assertEquals(1, build.size) - assertEquals("""fn init_semantic(model: Vec, tokenizer_data: Vec) -> Result, SemanticError> { + assertEquals( + """fn init_semantic(model: Vec, tokenizer_data: Vec) -> Result, SemanticError> { let result = Semantic::init_semantic(model, tokenizer_data)?; Ok(Arc::new(result)) }""", build[0].underTestCode)