Add test for fieldIsMandatory

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
Somtochi Onyekwere
2021-09-20 23:17:27 +01:00
parent 374a55d8f5
commit 00e993c686
+27
View File
@@ -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)
}
}