-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added exception handling for methodReturn query (#903)
* refactor test cases * add exception handling fro methodReturn query
- Loading branch information
1 parent
09d684f
commit daf5245
Showing
2 changed files
with
89 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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
55 changes: 55 additions & 0 deletions
55
...test/scala/ai/privado/languageEngine/ruby/passes/MethodFullNameForExternalNodesTest.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ai.privado.languageEngine.ruby.passes | ||
|
||
import ai.privado.cache.RuleCache | ||
import org.scalatest.BeforeAndAfterAll | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AnyWordSpec | ||
import io.shiftleft.semanticcpg.language.* | ||
import ai.privado.utility.Utilities.resolver | ||
import ai.privado.languageEngine.ruby.RubyTestBase.* | ||
import ai.privado.languageEngine.ruby.passes.download.DownloadDependenciesPass | ||
import io.joern.rubysrc2cpg.RubySrc2Cpg | ||
import io.joern.rubysrc2cpg.deprecated.utils.PackageTable | ||
class MethodFullNameForExternalNodesTest extends AnyWordSpec with Matchers with BeforeAndAfterAll { | ||
|
||
"method fullname for external nodes accessed via scopeResolution" should { | ||
|
||
"be resolved" in { | ||
val (cpg, config) = code( | ||
List( | ||
SourceCodeModel( | ||
""" | ||
|class MyClass | ||
| def foo | ||
| zendesk_user = ZendeskAPI::User.create_or_update!( | ||
| external_id: user.strong_id, | ||
| email: user.email, | ||
| name: user.name, | ||
| user_fields: user_fields(user), | ||
| ) | ||
| end | ||
|end | ||
|""".stripMargin, | ||
"demo.rb" | ||
), | ||
SourceCodeModel( | ||
""" | ||
|source 'https://rubygems.org' | ||
|gem 'zendesk_api' | ||
|""".stripMargin, | ||
"Gemfile" | ||
) | ||
) | ||
) | ||
|
||
val packageTable = | ||
new DownloadDependenciesPass(new PackageTable(), config.inputPath, RuleCache()).createAndApply() | ||
new RubyExternalTypesPass(cpg, packageTable).createAndApply() | ||
|
||
cpg.call("create_or_update!").dynamicTypeHintFullName.l shouldBe List( | ||
"zendesk_api::program.ZendeskAPI.User.create_or_update!" | ||
) | ||
|
||
} | ||
} | ||
} |