Search in sources :

Example 1 with GoContext

use of org.sonar.go.plugin.GoCoverageReport.GoContext in project sonar-go by SonarSource.

the class GoCoverageReportTest method parse_coverage_linux_absolute.

@Test
void parse_coverage_linux_absolute() throws IOException {
    Path coverageFile = COVERAGE_DIR.resolve("coverage.linux.absolute.out");
    GoContext linuxContext = new GoContext('/', "/home/paul/go");
    String coverPath = "/home/paul/dev/github/SonarSource/sonar-go/sonar-go-plugin/src/test/resources/coverage/cover.go";
    assertCoverGo(coverageFile, linuxContext, coverPath);
}
Also used : Path(java.nio.file.Path) GoContext(org.sonar.go.plugin.GoCoverageReport.GoContext) Test(org.junit.jupiter.api.Test)

Example 2 with GoContext

use of org.sonar.go.plugin.GoCoverageReport.GoContext in project sonar-go by SonarSource.

the class GoCoverageReportTest method parse_coverage_windows_absolute.

@Test
void parse_coverage_windows_absolute() throws IOException {
    Path coverageFile = COVERAGE_DIR.resolve("coverage.win.absolute.out");
    GoContext windowsContext = new GoContext('\\', "C:\\Users\\paul\\go");
    String coverPath = "C:\\Users\\paul\\dev\\github\\SonarSource\\sonar-go\\sonar-go-plugin\\src\\test\\resources\\coverage\\cover.go";
    assertCoverGo(coverageFile, windowsContext, coverPath);
}
Also used : Path(java.nio.file.Path) GoContext(org.sonar.go.plugin.GoCoverageReport.GoContext) Test(org.junit.jupiter.api.Test)

Example 3 with GoContext

use of org.sonar.go.plugin.GoCoverageReport.GoContext in project sonar-go by SonarSource.

the class GoCoverageReportTest method coverage.

@Test
void coverage() {
    GoContext linuxContext = new GoContext('/', "/home/paul/go");
    Coverage coverage = new Coverage(linuxContext);
    coverage.add(new CoverageStat(2, "main.go:2.2,2.5 1 1"));
    coverage.add(new CoverageStat(3, "main.go:4.2,4.7 1 0"));
    coverage.add(new CoverageStat(4, "other.go:3.2,4.12 1 1"));
    assertThat(coverage.fileMap.keySet()).containsExactlyInAnyOrder("/home/paul/go/main.go", "/home/paul/go/other.go");
    assertThat(coverage.fileMap.get("/home/paul/go/main.go").lineMap.keySet()).containsExactlyInAnyOrder(2, 4);
    assertThat(coverage.fileMap.get("/home/paul/go/other.go").lineMap.keySet()).containsExactlyInAnyOrder(3, 4);
}
Also used : CoverageStat(org.sonar.go.plugin.GoCoverageReport.CoverageStat) GoContext(org.sonar.go.plugin.GoCoverageReport.GoContext) LineCoverage(org.sonar.go.plugin.GoCoverageReport.LineCoverage) Coverage(org.sonar.go.plugin.GoCoverageReport.Coverage) FileCoverage(org.sonar.go.plugin.GoCoverageReport.FileCoverage) Test(org.junit.jupiter.api.Test)

Example 4 with GoContext

use of org.sonar.go.plugin.GoCoverageReport.GoContext in project sonar-go by SonarSource.

the class GoCoverageReportTest method coverage_stat_resolve_path.

@Test
void coverage_stat_resolve_path() {
    CoverageStat coverage;
    GoContext linuxContext = new GoContext('/', "/home/paul/go");
    GoContext windowsContext = new GoContext('\\', "C:\\Users\\paul\\go");
    coverage = new CoverageStat(2, "_/my-app/my-app.go:2.2,2.5 1 0");
    assertThat(coverage.resolvePath(linuxContext)).isEqualTo("/my-app/my-app.go");
    coverage = new CoverageStat(2, "my-app/my-app.go:2.2,2.5 1 0");
    assertThat(coverage.resolvePath(linuxContext)).isEqualTo("/home/paul/go/my-app/my-app.go");
    coverage = new CoverageStat(2, "_\\C_\\my-app\\my-app.go:2.2,2.5 1 0");
    assertThat(coverage.resolvePath(windowsContext)).isEqualTo("C:\\my-app\\my-app.go");
    coverage = new CoverageStat(2, "my-app\\my-app.go:2.2,2.5 1 0");
    assertThat(coverage.resolvePath(windowsContext)).isEqualTo("C:\\Users\\paul\\go\\my-app\\my-app.go");
    linuxContext = new GoContext('/', null);
    coverage = new CoverageStat(2, "my-app/my-app.go:2.2,2.5 1 0");
    assertThat(coverage.resolvePath(linuxContext)).isEqualTo("my-app/my-app.go");
}
Also used : CoverageStat(org.sonar.go.plugin.GoCoverageReport.CoverageStat) GoContext(org.sonar.go.plugin.GoCoverageReport.GoContext) Test(org.junit.jupiter.api.Test)

Example 5 with GoContext

use of org.sonar.go.plugin.GoCoverageReport.GoContext in project sonar-go by SonarSource.

the class GoCoverageReportTest method parse_coverage_linux_relative.

@Test
void parse_coverage_linux_relative() throws IOException {
    Path coverageFile = COVERAGE_DIR.resolve("coverage.linux.relative.out");
    GoContext linuxContext = new GoContext('/', "/home/paul/go");
    String coverPath = "/home/paul/go/github.com/SonarSource/sonar-go/sonar-go-plugin/src/test/resources/coverage/cover.go";
    assertCoverGo(coverageFile, linuxContext, coverPath);
}
Also used : Path(java.nio.file.Path) GoContext(org.sonar.go.plugin.GoCoverageReport.GoContext) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)7 GoContext (org.sonar.go.plugin.GoCoverageReport.GoContext)7 Path (java.nio.file.Path)5 CoverageStat (org.sonar.go.plugin.GoCoverageReport.CoverageStat)2 SensorContextTester (org.sonar.api.batch.sensor.internal.SensorContextTester)1 MapSettings (org.sonar.api.config.internal.MapSettings)1 Coverage (org.sonar.go.plugin.GoCoverageReport.Coverage)1 FileCoverage (org.sonar.go.plugin.GoCoverageReport.FileCoverage)1 LineCoverage (org.sonar.go.plugin.GoCoverageReport.LineCoverage)1