Add unit test

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-05-30 16:36:43 +00:00
parent e657e1eb14
commit 69fcf97583
3 changed files with 142 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testing
import (
"io"
"github.com/kubernetes-incubator/cri-containerd/pkg/server/agents"
)
// FakeAgent is a fake agent for test.
type FakeAgent struct{}
// Start always return nil not.
// TODO(random-liu): Inject error and test error.
func (f *FakeAgent) Start() error {
return nil
}
// FakeAgentFactory is a fake agent factory for test.
type FakeAgentFactory struct{}
// NewFakeAgentFactory creates fake agent factory.
func NewFakeAgentFactory() agents.AgentFactory {
return &FakeAgentFactory{}
}
// NewSandboxLogger creates a fake agent as sandbox logger.
func (*FakeAgentFactory) NewSandboxLogger(rc io.ReadCloser) agents.Agent {
return &FakeAgent{}
}
// NewContainerLogger creates a fake agent as container logger.
func (*FakeAgentFactory) NewContainerLogger(string, agents.StreamType, io.ReadCloser) agents.Agent {
return &FakeAgent{}
}