@@ -23,6 +23,7 @@ import (
2323 "time"
2424
2525 "github.com/NVIDIA/aicr/pkg/validator"
26+ "github.com/NVIDIA/aicr/pkg/validator/checks"
2627
2728 // Import conformance checks to register them.
2829 _ "github.com/NVIDIA/aicr/pkg/validator/checks/conformance"
@@ -337,3 +338,105 @@ func TestRenderIndexContent(t *testing.T) {
337338 t .Error ("index.md should contain run ID" )
338339 }
339340}
341+
342+ func TestRenderWithArtifacts (t * testing.T ) {
343+ dir := t .TempDir ()
344+ r := New (WithOutputDir (dir ))
345+
346+ result := & validator.ValidationResult {
347+ RunID : "test-artifacts" ,
348+ Phases : map [string ]* validator.PhaseResult {
349+ "conformance" : {
350+ Checks : []validator.CheckResult {
351+ {
352+ Name : "dra-support" ,
353+ Status : validator .ValidationStatusPass ,
354+ Reason : "DRA controller healthy" ,
355+ Duration : 5 * time .Second ,
356+ Artifacts : []checks.Artifact {
357+ {Label : "DRA Controller Pods" , Data : "NAME READY STATUS\n dra-controller-abc12 1/1 Running" },
358+ {Label : "ResourceSlice Count" , Data : "Total ResourceSlices: 8" },
359+ },
360+ },
361+ },
362+ },
363+ },
364+ }
365+
366+ if err := r .Render (context .Background (), result ); err != nil {
367+ t .Fatalf ("Render() error = %v" , err )
368+ }
369+
370+ content , err := os .ReadFile (filepath .Join (dir , "dra-support.md" ))
371+ if err != nil {
372+ t .Fatalf ("failed to read dra-support.md: %v" , err )
373+ }
374+
375+ s := string (content )
376+
377+ // Verify artifact labels are present.
378+ if ! strings .Contains (s , "#### DRA Controller Pods" ) {
379+ t .Error ("evidence should contain artifact label 'DRA Controller Pods'" )
380+ }
381+ if ! strings .Contains (s , "#### ResourceSlice Count" ) {
382+ t .Error ("evidence should contain artifact label 'ResourceSlice Count'" )
383+ }
384+
385+ // Verify artifact data is present.
386+ if ! strings .Contains (s , "dra-controller-abc12" ) {
387+ t .Error ("evidence should contain artifact data" )
388+ }
389+ if ! strings .Contains (s , "Total ResourceSlices: 8" ) {
390+ t .Error ("evidence should contain ResourceSlice count data" )
391+ }
392+
393+ // Verify the reason is also present (artifacts don't replace reason).
394+ if ! strings .Contains (s , "DRA controller healthy" ) {
395+ t .Error ("evidence should still contain the reason text" )
396+ }
397+ }
398+
399+ func TestRenderWithoutArtifacts (t * testing.T ) {
400+ dir := t .TempDir ()
401+ r := New (WithOutputDir (dir ))
402+
403+ result := & validator.ValidationResult {
404+ RunID : "test-no-artifacts" ,
405+ Phases : map [string ]* validator.PhaseResult {
406+ "conformance" : {
407+ Checks : []validator.CheckResult {
408+ {
409+ Name : "dra-support" ,
410+ Status : validator .ValidationStatusPass ,
411+ Reason : "all healthy" ,
412+ Duration : 3 * time .Second ,
413+ },
414+ },
415+ },
416+ },
417+ }
418+
419+ if err := r .Render (context .Background (), result ); err != nil {
420+ t .Fatalf ("Render() error = %v" , err )
421+ }
422+
423+ content , err := os .ReadFile (filepath .Join (dir , "dra-support.md" ))
424+ if err != nil {
425+ t .Fatalf ("failed to read dra-support.md: %v" , err )
426+ }
427+
428+ s := string (content )
429+
430+ // Verify basic content is present.
431+ if ! strings .Contains (s , "dra-support" ) {
432+ t .Error ("evidence should contain check name" )
433+ }
434+ if ! strings .Contains (s , "all healthy" ) {
435+ t .Error ("evidence should contain reason" )
436+ }
437+
438+ // Verify no artifact headers appear.
439+ if strings .Contains (s , "####" ) {
440+ t .Error ("evidence without artifacts should not contain #### headers" )
441+ }
442+ }
0 commit comments