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);
}
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);
}
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);
}
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");
}
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);
}
Aggregations