Merge pull request #13780 from smarterclayton/pod_logs
Auto commit by PR queue bot
This commit is contained in:
@@ -3866,3 +3866,34 @@ func fakeValidSecurityContext(priv bool) *api.SecurityContext {
|
||||
Privileged: &priv,
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidPodLogOptions(t *testing.T) {
|
||||
now := unversioned.Now()
|
||||
negative := int64(-1)
|
||||
zero := int64(0)
|
||||
positive := int64(1)
|
||||
tests := []struct {
|
||||
opt api.PodLogOptions
|
||||
errs int
|
||||
}{
|
||||
{api.PodLogOptions{}, 0},
|
||||
{api.PodLogOptions{Previous: true}, 0},
|
||||
{api.PodLogOptions{Follow: true}, 0},
|
||||
{api.PodLogOptions{TailLines: &zero}, 0},
|
||||
{api.PodLogOptions{TailLines: &negative}, 1},
|
||||
{api.PodLogOptions{TailLines: &positive}, 0},
|
||||
{api.PodLogOptions{LimitBytes: &zero}, 1},
|
||||
{api.PodLogOptions{LimitBytes: &negative}, 1},
|
||||
{api.PodLogOptions{LimitBytes: &positive}, 0},
|
||||
{api.PodLogOptions{SinceSeconds: &negative}, 1},
|
||||
{api.PodLogOptions{SinceSeconds: &positive}, 0},
|
||||
{api.PodLogOptions{SinceSeconds: &zero}, 1},
|
||||
{api.PodLogOptions{SinceTime: &now}, 0},
|
||||
}
|
||||
for i, test := range tests {
|
||||
errs := ValidatePodLogOptions(&test.opt)
|
||||
if test.errs != len(errs) {
|
||||
t.Errorf("%d: Unexpected errors: %v", i, errs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user