use of com.google.idea.blaze.base.model.MockBlazeProjectDataManager in project intellij by bazelbuild.
the class BlazeGoTestEventsHandlerTest method testFunctionLocationResolves.
@Test
public void testFunctionLocationResolves() {
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//foo/bar:foo_test").setKind("go_test").setBuildFile(src("foo/bar/BUILD")).addSource(src("foo/bar/foo_test.go")).setGoInfo(GoIdeInfo.builder().addSources(ImmutableList.of(src("foo/bar/foo_test.go"))).setImportPath("google3/foo/bar/foo"))).build();
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(new BlazeProjectData(0L, targetMap, null, null, new WorkspacePathResolverImpl(workspaceRoot), location -> workspaceRoot.fileForPath(new WorkspacePath(location.getRelativePath())), new WorkspaceLanguageSettings(WorkspaceType.GO, ImmutableSet.of(LanguageClass.GO)), null, null)));
GoFile goFile = (GoFile) workspace.createPsiFile(new WorkspacePath("foo/bar/foo_test.go"), "package foo", "import \"testing\"", "func TestFoo(t *testing.T) {}");
workspace.createFile(new WorkspacePath("foo/bar/BUILD"), "go_test(", " name = 'foo_test',", " srcs = ['foo_test.go'],", ")");
GoFunctionDeclaration function = PsiUtils.findFirstChildOfClassRecursive(goFile, GoFunctionDeclaration.class);
assertThat(function).isNotNull();
String url = handler.testLocationUrl(null, "foo/bar/foo_test", "TestFoo", null);
Location<?> location = getLocation(url);
assertThat(location).isNotNull();
assertThat(location.getPsiElement()).isEqualTo(function);
}
use of com.google.idea.blaze.base.model.MockBlazeProjectDataManager in project intellij by bazelbuild.
the class BlazeGoTestEventsHandlerTest method testSuiteLocationResolvesToSingleSourceFile.
@Test
public void testSuiteLocationResolvesToSingleSourceFile() {
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//foo/bar:foo_test").setKind("go_test").setBuildFile(src("foo/bar/BUILD")).addSource(src("foo/bar/foo_test.go")).setGoInfo(GoIdeInfo.builder().addSources(ImmutableList.of(src("foo/bar/foo_test.go"))).setImportPath("google3/foo/bar/foo"))).build();
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(new BlazeProjectData(0L, targetMap, null, null, new WorkspacePathResolverImpl(workspaceRoot), location -> workspaceRoot.fileForPath(new WorkspacePath(location.getRelativePath())), new WorkspaceLanguageSettings(WorkspaceType.GO, ImmutableSet.of(LanguageClass.GO)), null, null)));
GoFile goFile = (GoFile) workspace.createPsiFile(new WorkspacePath("foo/bar/foo_test.go"), "package foo", "import \"testing\"", "func TestFoo(t *testing.T) {}");
workspace.createFile(new WorkspacePath("foo/bar/BUILD"), "go_test(", " name = 'foo_test',", " srcs = ['foo_test.go'],", ")");
String url = handler.suiteLocationUrl(null, "foo/bar/foo_test");
Location<?> location = getLocation(url);
assertThat(location).isNotNull();
assertThat(location.getPsiElement()).isEqualTo(goFile);
}
use of com.google.idea.blaze.base.model.MockBlazeProjectDataManager in project intellij by bazelbuild.
the class ProjectViewCompletionTest method doSetup.
@Before
public final void doSetup() {
BlazeProjectDataManager mockProjectDataManager = new MockBlazeProjectDataManager(MockBlazeProjectDataBuilder.builder(workspaceRoot).build());
registerProjectService(BlazeProjectDataManager.class, mockProjectDataManager);
editorTest = new EditorTestHelper(getProject(), testFixture);
}
Aggregations