@@ -2,6 +2,7 @@ package scanner
2
2
3
3
import (
4
4
"context"
5
+ "github.com/boostsecurityio/poutine/models"
5
6
"github.com/boostsecurityio/poutine/opa"
6
7
"github.com/stretchr/testify/assert"
7
8
"testing"
@@ -69,3 +70,53 @@ func TestRun(t *testing.T) {
69
70
assert .Contains (t , s .Package .PackageDependencies , "pkg:docker/alpine%3Alatest" )
70
71
assert .Equal (t , 3 , len (s .Package .GitlabciConfigs ))
71
72
}
73
+
74
+ func TestPipelineAsCodeTekton (t * testing.T ) {
75
+ s := NewScanner ("testdata" )
76
+ o , _ := opa .NewOpa ()
77
+ err := s .Run (context .TODO (), o )
78
+ assert .NoError (t , err )
79
+
80
+ pipelines := s .Package .PipelineAsCodeTekton
81
+
82
+ assert .Len (t , pipelines , 1 )
83
+ expectedAnnotations := map [string ]string {
84
+ "pipelinesascode.tekton.dev/on-event" : "[push, pull_request]" ,
85
+ "pipelinesascode.tekton.dev/on-target-branch" : "[*]" ,
86
+ "pipelinesascode.tekton.dev/task" : "[git-clone]" ,
87
+ }
88
+ expectedPipeline := models.PipelineAsCodeTekton {
89
+ ApiVersion : "tekton.dev/v1beta1" ,
90
+ Kind : "PipelineRun" ,
91
+ Metadata : struct {
92
+ Name string `json:"name"`
93
+ Annotations map [string ]string `json:"annotations"`
94
+ }{
95
+ Name : "linters" ,
96
+ Annotations : expectedAnnotations ,
97
+ },
98
+ Spec : models.PipelineRunSpec {
99
+ PipelineSpec : & models.PipelineSpec {
100
+ Tasks : []models.PipelineTask {
101
+ {
102
+ Name : "fetchit" ,
103
+ },
104
+ {
105
+ Name : "vale" ,
106
+ TaskSpec : & models.TaskSpec {
107
+ Steps : []models.Step {
108
+ {
109
+ Name : "vale-lint" ,
110
+ Script : "vale docs/content --minAlertLevel=error --output=line\n " ,
111
+ Lines : map [string ]int {"script" : 43 , "start" : 40 },
112
+ },
113
+ },
114
+ },
115
+ },
116
+ },
117
+ },
118
+ },
119
+ }
120
+ assert .Equal (t , expectedPipeline .Metadata , pipelines [0 ].Metadata )
121
+ assert .Equal (t , expectedPipeline .Spec .PipelineSpec .Tasks [1 ].TaskSpec .Steps [0 ], pipelines [0 ].Spec .PipelineSpec .Tasks [1 ].TaskSpec .Steps [0 ])
122
+ }
0 commit comments