// ĠCopyright Ġ 2 0 2 0 ĠAmazon . com , ĠInc . Ġor Ġits Ġaffiliates . ĠAll ĠRights ĠReserved . Ċ // ĠSPDX - License - Identifier : ĠApache - 2 . 0 Ċ Ċ package Ġsoftware . aws . tool k its . jetbrains . services . lambda . go Ċ Ċ import Ġcom . intellij . openapi . roots . Project File Index Ċ import Ġcom . intellij . openapi . vfs . V fs Util Core Ċ import Ġcom . intellij . test Framework . run In Ed t And Wait Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġsoftware . aws . tool k its . jetbrains . utils . rules . Go Code Insight TestFixture Rule Ċ import Ġsoftware . aws . tool k its . jetbrains . utils . rules . add Go Lambda Handler Ċ import Ġsoftware . aws . tool k its . jetbrains . utils . rules . add Go Mod File Ċ Ċ class ĠGo Helper Test Ġ{ ĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġproject Rule Ġ= ĠGo Code Insight TestFixture Rule () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinfer Source Root _ no Go Mod Returns Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġelement Ġ= Ġproject Rule . fixture . add Go Lambda Handler ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsub Path Ġ= Ġ" foo / bar " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġrun In Ed t And Wait Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġsource Root Ġ= Ġinfer Source Root ( project Rule . project , Ġelement . containing File . virtual File ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( source Root ). isNull () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinfer Source Root _ go Mod In Sub Folder () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġelement Ġ= Ġproject Rule . fixture . add Go Lambda Handler ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsub Path Ġ= Ġ" foo / bar " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġproject Rule . fixture . add Go Mod File ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsub Path Ġ= Ġ" foo " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġrun In Ed t And Wait Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcontent Root Ġ= ĠProject File Index . getInstance ( project Rule . project ). getContent Root For File ( element . containing File . virtual File ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġsource Root Ġ= Ġinfer Source Root ( project Rule . project , Ġelement . containing File . virtual File ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( V fs Util Core . find Relative File (" foo ", Ġcontent Root )). isEqualTo ( source Root ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinfer Source Root _ go Mod In Root Folder () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġelement Ġ= Ġproject Rule . fixture . add Go Lambda Handler ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsub Path Ġ= Ġ" foo / bar " ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġproject Rule . fixture . add Go Mod File ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsub Path Ġ= Ġ"." ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġrun In Ed t And Wait Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcontent Root Ġ= ĠProject File Index . getInstance ( project Rule . project ). getContent Root For File ( element . containing File . virtual File ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġsource Root Ġ= Ġinfer Source Root ( project Rule . project , Ġelement . containing File . virtual File ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( content Root ). isEqualTo ( source Root ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ