mirror of
https://github.com/fluxcd/flagger.git
synced 2026-04-15 06:57:34 +00:00
Add test for fieldIsMandatory
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
@@ -372,3 +372,30 @@ func TestConfigTracker_HasConfigChanged_ShouldReturnErrorWhenAPIServerIsDown(t *
|
||||
assert.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_fieldIsMandatory(t *testing.T) {
|
||||
falsy := false
|
||||
truthy := true
|
||||
tests := []struct {
|
||||
optional *bool
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
optional: nil,
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
optional: &falsy,
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
optional: &truthy,
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
actual := fieldIsMandatory(tt.optional)
|
||||
assert.Equal(t, tt.expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user