use of com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder in project intellij by bazelbuild.
the class BlazeGoBinaryConfigurationProducerTest method testProducedFromGoFile.
@Test
public void testProducedFromGoFile() {
PsiFile goFile = createAndIndexFile(new WorkspacePath("foo/bar/main.go"), "package main", "func main() {}");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("go_binary").setLabel("//foo/bar:main").addSource(sourceRoot("foo/bar/main.go")).build()).build());
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
ConfigurationContext context = createContextFromPsi(goFile);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).isNotNull();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeGoBinaryConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//foo/bar:main"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.RUN);
}
use of com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder in project intellij by bazelbuild.
the class BlazeGoTestConfigurationProducerTest method testProducedFromGoFile.
@Test
public void testProducedFromGoFile() {
PsiFile goFile = createAndIndexFile(new WorkspacePath("foo/bar/foo_test.go"), "package foo", "import \"testing\"", "func TestFoo(t *testing.T) {}");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("go_test").setLabel("//foo/bar:foo_test").addSource(sourceRoot("foo/bar/foo_test.go")).build()).build());
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
ConfigurationContext context = createContextFromPsi(goFile);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).isNotNull();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeGoTestConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//foo/bar:foo_test"));
assertThat(getTestFilterContents(config)).isNull();
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
Aggregations