@@ -1513,7 +1513,8 @@ func TestWriteJSONWithDiscoveryWorkingDir(t *testing.T) {
15131513
15141514 // The name should be relative to the worktree dir, not the original repo dir
15151515 // Without the fix, this would be the full absolute path since unitPath doesn't start with originalRepoDir
1516- assert .Equal (t , "module/unit" , runs [0 ].Name , "Run name should be relative to DiscoveryWorkingDir, not report.workingDir" )
1516+ assert .Equal (t , "module/unit" , runs [0 ].Name ,
1517+ "Run name should be relative to DiscoveryWorkingDir, not report.workingDir" )
15171518}
15181519
15191520// TestWriteCSVWithDiscoveryWorkingDir verifies that CSV output also uses DiscoveryWorkingDir.
@@ -1554,7 +1555,8 @@ func TestWriteCSVWithDiscoveryWorkingDir(t *testing.T) {
15541555 require .Len (t , records , 2 ) // header + 1 data row
15551556
15561557 // The name (first column) should be relative to worktree dir
1557- assert .Equal (t , "module/unit" , records [1 ][0 ], "Run name should be relative to DiscoveryWorkingDir, not report.workingDir" )
1558+ assert .Equal (t , "module/unit" , records [1 ][0 ],
1559+ "Run name should be relative to DiscoveryWorkingDir, not report.workingDir" )
15581560}
15591561
15601562// TestParseJSONRuns verifies that JSON report data can be parsed from bytes.
@@ -1649,7 +1651,8 @@ func TestParseJSONRunsFromFile(t *testing.T) {
16491651 t .Parallel ()
16501652
16511653 reportFile := filepath .Join (tmp , "valid-report.json" )
1652- content := `[{"Name": "test-unit", "Started": "2024-01-01T10:00:00Z", "Ended": "2024-01-01T10:01:00Z", "Result": "succeeded"}]`
1654+ content := `[{"Name": "test-unit", "Started": "2024-01-01T10:00:00Z",` +
1655+ ` "Ended": "2024-01-01T10:01:00Z", "Result": "succeeded"}]`
16531656
16541657 err := os .WriteFile (reportFile , []byte (content ), 0644 )
16551658 require .NoError (t , err )
@@ -1773,9 +1776,15 @@ func TestParseCSVRuns(t *testing.T) {
17731776 expected : report.CSVRuns {},
17741777 },
17751778 {
1776- name : "single run" ,
1777- input : "Name,Started,Ended,Result,Reason,Cause,Ref,Cmd,Args\n module/unit,2024-01-01T10:00:00Z,2024-01-01T10:01:00Z,succeeded,,,,,\n " ,
1778- expected : report.CSVRuns {{Name : "module/unit" , Started : "2024-01-01T10:00:00Z" , Ended : "2024-01-01T10:01:00Z" , Result : "succeeded" }},
1779+ name : "single run" ,
1780+ input : "Name,Started,Ended,Result,Reason,Cause,Ref,Cmd,Args\n " +
1781+ "module/unit,2024-01-01T10:00:00Z,2024-01-01T10:01:00Z,succeeded,,,,,\n " ,
1782+ expected : report.CSVRuns {{
1783+ Name : "module/unit" ,
1784+ Started : "2024-01-01T10:00:00Z" ,
1785+ Ended : "2024-01-01T10:01:00Z" ,
1786+ Result : "succeeded" ,
1787+ }},
17791788 },
17801789 {
17811790 name : "multiple runs with all fields" ,
@@ -1784,8 +1793,25 @@ unit-a,2024-01-01T10:00:00Z,2024-01-01T10:01:00Z,succeeded,,,HEAD~1,plan,-out=pl
17841793unit-b,2024-01-01T10:01:00Z,2024-01-01T10:02:00Z,failed,run error,some error,main,apply,
17851794` ,
17861795 expected : report.CSVRuns {
1787- {Name : "unit-a" , Started : "2024-01-01T10:00:00Z" , Ended : "2024-01-01T10:01:00Z" , Result : "succeeded" , Ref : "HEAD~1" , Cmd : "plan" , Args : "-out=plan.tfplan|-var=foo=bar" },
1788- {Name : "unit-b" , Started : "2024-01-01T10:01:00Z" , Ended : "2024-01-01T10:02:00Z" , Result : "failed" , Reason : "run error" , Cause : "some error" , Ref : "main" , Cmd : "apply" },
1796+ {
1797+ Name : "unit-a" ,
1798+ Started : "2024-01-01T10:00:00Z" ,
1799+ Ended : "2024-01-01T10:01:00Z" ,
1800+ Result : "succeeded" ,
1801+ Ref : "HEAD~1" ,
1802+ Cmd : "plan" ,
1803+ Args : "-out=plan.tfplan|-var=foo=bar" ,
1804+ },
1805+ {
1806+ Name : "unit-b" ,
1807+ Started : "2024-01-01T10:01:00Z" ,
1808+ Ended : "2024-01-01T10:02:00Z" ,
1809+ Result : "failed" ,
1810+ Reason : "run error" ,
1811+ Cause : "some error" ,
1812+ Ref : "main" ,
1813+ Cmd : "apply" ,
1814+ },
17891815 },
17901816 },
17911817 {
@@ -1832,7 +1858,8 @@ func TestParseCSVRunsFromFile(t *testing.T) {
18321858 t .Parallel ()
18331859
18341860 reportFile := filepath .Join (tmp , "valid-report.csv" )
1835- content := "Name,Started,Ended,Result,Reason,Cause,Ref,Cmd,Args\n test-unit,2024-01-01T10:00:00Z,2024-01-01T10:01:00Z,succeeded,,,,,\n "
1861+ content := "Name,Started,Ended,Result,Reason,Cause,Ref,Cmd,Args\n " +
1862+ "test-unit,2024-01-01T10:00:00Z,2024-01-01T10:01:00Z,succeeded,,,,,\n "
18361863
18371864 err := os .WriteFile (reportFile , []byte (content ), 0644 )
18381865 require .NoError (t , err )
@@ -1974,10 +2001,13 @@ func TestParseJSONRunsFromFileValidation(t *testing.T) {
19742001 },
19752002 {
19762003 name : "valid multiple runs" ,
1977- input : `[
1978- {"Name": "unit-a", "Started": "2024-01-01T10:00:00Z", "Ended": "2024-01-01T10:01:00Z", "Result": "succeeded"},
1979- {"Name": "unit-b", "Started": "2024-01-01T10:01:00Z", "Ended": "2024-01-01T10:02:00Z", "Result": "failed", "Reason": "run error"}
1980- ]` ,
2004+ input : "[" +
2005+ `{"Name": "unit-a", "Started": "2024-01-01T10:00:00Z",` +
2006+ ` "Ended": "2024-01-01T10:01:00Z", "Result": "succeeded"},` +
2007+ `{"Name": "unit-b", "Started": "2024-01-01T10:01:00Z",` +
2008+ ` "Ended": "2024-01-01T10:02:00Z", "Result": "failed",` +
2009+ ` "Reason": "run error"}` +
2010+ "]" ,
19812011 expectError : false ,
19822012 },
19832013 {
0 commit comments