5
5
"testing"
6
6
7
7
"github.com/stretchr/testify/assert"
8
+ "github.com/stretchr/testify/require"
9
+ "gopkg.in/yaml.v3"
8
10
)
9
11
10
12
func TestReadWorkflow_StringEvent (t * testing.T ) {
@@ -367,10 +369,9 @@ func TestReadWorkflow_Strategy(t *testing.T) {
367
369
assert .NoError (t , err )
368
370
assert .Equal (t , matrixes ,
369
371
[]map [string ]interface {}{
370
- {"datacenter" : "site-c" , "node-version" : "14.x" , "site" : "staging" },
371
- {"datacenter" : "site-c" , "node-version" : "16.x" , "site" : "staging" },
372
- {"datacenter" : "site-d" , "node-version" : "16.x" , "site" : "staging" },
373
- {"php-version" : 5.4 },
372
+ {"datacenter" : "site-c" , "node-version" : "14.x" , "site" : "staging" , "php-version" : 5.4 },
373
+ {"datacenter" : "site-c" , "node-version" : "16.x" , "site" : "staging" , "php-version" : 5.4 },
374
+ {"datacenter" : "site-d" , "node-version" : "16.x" , "site" : "staging" , "php-version" : 5.4 },
374
375
{"datacenter" : "site-a" , "node-version" : "10.x" , "site" : "prod" },
375
376
{"datacenter" : "site-b" , "node-version" : "12.x" , "site" : "dev" },
376
377
},
@@ -394,6 +395,32 @@ func TestReadWorkflow_Strategy(t *testing.T) {
394
395
assert .Equal (t , job .Strategy .FailFast , false )
395
396
}
396
397
398
+ func TestMatrixOnlyIncludes (t * testing.T ) {
399
+ matrix := map [string ][]interface {}{
400
+ "include" : []interface {}{
401
+ map [string ]interface {}{"a" : "1" , "b" : "2" },
402
+ map [string ]interface {}{"a" : "3" , "b" : "4" },
403
+ },
404
+ }
405
+ rN := yaml.Node {}
406
+ err := rN .Encode (matrix )
407
+ require .NoError (t , err , "encoding matrix should succeed" )
408
+ job := & Job {
409
+ Strategy : & Strategy {
410
+ RawMatrix : rN ,
411
+ },
412
+ }
413
+ assert .Equal (t , job .Matrix (), matrix )
414
+ matrixes , err := job .GetMatrixes ()
415
+ require .NoError (t , err )
416
+ assert .Equal (t , matrixes ,
417
+ []map [string ]interface {}{
418
+ {"a" : "1" , "b" : "2" },
419
+ {"a" : "3" , "b" : "4" },
420
+ },
421
+ )
422
+ }
423
+
397
424
func TestStep_ShellCommand (t * testing.T ) {
398
425
tests := []struct {
399
426
shell string
0 commit comments