1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-15 17:51:20 +00:00
kyverno/cmd/cli/kubectl-kyverno/test/test_cases_test.go
Charles-Edouard Brétéché cdd8b4383f
refactor: cli test command test execution (#8266)
* refactor: cli test command test execution

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* error

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* tests

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-09-05 13:19:05 +00:00

66 lines
1.1 KiB
Go

package test
import (
"errors"
"reflect"
"testing"
)
func TestTestCases_Errors(t *testing.T) {
tests := []struct {
name string
tc TestCases
want []TestCase
}{{
name: "nil",
tc: nil,
want: nil,
}, {
name: "empty",
tc: []TestCase{},
want: nil,
}, {
name: "no error",
tc: TestCases([]TestCase{{}}),
want: nil,
}, {
name: "one error",
tc: []TestCase{{
Err: errors.New("error 1"),
}},
want: []TestCase{{
Err: errors.New("error 1"),
}},
}, {
name: "two errors",
tc: []TestCase{{
Err: errors.New("error 1"),
}, {
Err: errors.New("error 2"),
}},
want: []TestCase{{
Err: errors.New("error 1"),
}, {
Err: errors.New("error 2"),
}},
}, {
name: "mixed",
tc: []TestCase{{
Err: errors.New("error 1"),
}, {}, {
Err: errors.New("error 2"),
}, {}},
want: []TestCase{{
Err: errors.New("error 1"),
}, {
Err: errors.New("error 2"),
}},
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.tc.Errors(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("TestCases.Errors() = %v, want %v", got, tt.want)
}
})
}
}