56ec36726b
This fixes #499, where a matrix strategy with only include keys ends up causing multiple builds. This bugs appears to have been introduced in #415, when extra include keys are added in the matrix strategy. The cause seems to be because the CartesianProduct function returns an item with empty keys, instead of return an empty set. Co-authored-by: Ed Tan <edtan@users.noreply.github.com>
40 lines
713 B
Go
40 lines
713 B
Go
package common
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCartesianProduct(t *testing.T) {
|
|
assert := assert.New(t)
|
|
input := map[string][]interface{}{
|
|
"foo": {1, 2, 3, 4},
|
|
"bar": {"a", "b", "c"},
|
|
"baz": {false, true},
|
|
}
|
|
|
|
output := CartesianProduct(input)
|
|
assert.Len(output, 24)
|
|
|
|
for _, v := range output {
|
|
assert.Len(v, 3)
|
|
|
|
assert.Contains(v, "foo")
|
|
assert.Contains(v, "bar")
|
|
assert.Contains(v, "baz")
|
|
}
|
|
|
|
input = map[string][]interface{}{
|
|
"foo": {1, 2, 3, 4},
|
|
"bar": {},
|
|
"baz": {false, true},
|
|
}
|
|
output = CartesianProduct(input)
|
|
assert.Len(output, 0)
|
|
|
|
input = map[string][]interface{}{}
|
|
output = CartesianProduct(input)
|
|
assert.Len(output, 0)
|
|
}
|
|
|