55 "testing"
66
77 "github.com/stretchr/testify/assert"
8+ "github.com/stretchr/testify/require"
9+ "gopkg.in/yaml.v3"
810)
911
1012func TestReadWorkflow_StringEvent (t * testing.T ) {
@@ -367,10 +369,9 @@ func TestReadWorkflow_Strategy(t *testing.T) {
367369 assert .NoError (t , err )
368370 assert .Equal (t , matrixes ,
369371 []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 },
374375 {"datacenter" : "site-a" , "node-version" : "10.x" , "site" : "prod" },
375376 {"datacenter" : "site-b" , "node-version" : "12.x" , "site" : "dev" },
376377 },
@@ -394,6 +395,32 @@ func TestReadWorkflow_Strategy(t *testing.T) {
394395 assert .Equal (t , job .Strategy .FailFast , false )
395396}
396397
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+
397424func TestStep_ShellCommand (t * testing.T ) {
398425 tests := []struct {
399426 shell string
0 commit comments