Files
act_runner/internal/model/strategy_utils_test.go
silverwind b0ec3fa4fc fmt
2026-02-24 08:17:17 +01:00

71 lines
955 B
Go

package model
import (
"testing"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
)
type EmptyTraceWriter struct{}
func (e *EmptyTraceWriter) Info(_ string, _ ...any) {
}
func TestStrategy(t *testing.T) {
table := []struct {
content string
flatmatrix int
includematrix int
}{
{`
matrix:
label:
- a
- b
fields:
- a
- b
`, 4, 0},
{
`
matrix:
label:
- a
- b
include:
- label: a
x: self`, 2, 0,
},
{
`
matrix:
label:
- a
- b
include:
- label: c
x: self`, 2, 1,
},
{
`
matrix:
label:
- a
- b
exclude:
- label: a`, 1, 0,
},
}
for _, tc := range table {
var strategy Strategy
err := yaml.Unmarshal([]byte(tc.content), &strategy)
require.NoError(t, err)
res, err := ExpandStrategy(&strategy, &EmptyTraceWriter{})
require.NoError(t, err)
require.Len(t, res.FlatMatrix, tc.flatmatrix)
require.Len(t, res.IncludeMatrix, tc.includematrix)
}
}