test

package
v1.1.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Copyright 2018 the Velero contributors.

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.

Copyright 2018 the Velero contributors.

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.

Copyright 2018 the Velero contributors.

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDeepEqual added in v0.9.0

func AssertDeepEqual(t *testing.T, expected, actual interface{}) bool

AssertDeepEqual asserts the semantic equality of objects. This function exists in order to make sure time.Time and metav1.Time objects can be compared correctly. See https://github.com/stretchr/testify/issues/502.

func AssertErrorMatches added in v0.10.0

func AssertErrorMatches(t *testing.T, expected string, actual error) bool

AssertErrorMatches asserts that if expected is the empty string, actual is nil, otherwise, that actual's error string matches expected.

func CompareActions added in v0.8.0

func CompareActions(t *testing.T, expected, actual []core.Action)

CompareActions checks slices of actual and expected Actions for equality (ignoring order). It checks that the lengths of the slices are the same, that each actual Action has a corresponding expected Action, and that each expected Action has a corresponding actual Action.

func GetAsMap added in v0.9.0

func GetAsMap(j string) (map[string]interface{}, error)

func NewLogger added in v0.5.0

func NewLogger() logrus.FieldLogger

func TimesAreEqual added in v0.9.0

func TimesAreEqual(t1, t2 time.Time) bool

TimesAreEqual compares two times for equality. This function is used by equality.Semantic.DeepEqual to compare two time objects without having to call a method.

func UnstructuredOrDie added in v0.9.0

func UnstructuredOrDie(data string) *unstructured.Unstructured

func ValidatePatch added in v0.9.0

func ValidatePatch(t *testing.T, action core.Action, expected interface{}, decodeFunc func(*json.Decoder) (interface{}, error))

ValidatePatch tests the validity of an action. It checks that the action is a PatchAction, that the patch decodes from JSON with the provided decode func and has no extraneous fields, and that the decoded patch matches the expected.

Types

type FakeDiscoveryHelper added in v0.4.0

type FakeDiscoveryHelper struct {
	ResourceList       []*metav1.APIResourceList
	Mapper             meta.RESTMapper
	AutoReturnResource bool
	APIGroupsList      []metav1.APIGroup
}

func NewFakeDiscoveryHelper added in v0.5.0

func NewFakeDiscoveryHelper(autoReturnResource bool, resources map[schema.GroupVersionResource]schema.GroupVersionResource) *FakeDiscoveryHelper

func (*FakeDiscoveryHelper) APIGroups added in v0.9.1

func (dh *FakeDiscoveryHelper) APIGroups() []metav1.APIGroup

func (*FakeDiscoveryHelper) Refresh added in v0.4.0

func (dh *FakeDiscoveryHelper) Refresh() error

func (*FakeDiscoveryHelper) ResourceFor added in v0.5.0

func (*FakeDiscoveryHelper) Resources added in v0.4.0

func (dh *FakeDiscoveryHelper) Resources() []*metav1.APIResourceList

type FakeDynamicClient

type FakeDynamicClient struct {
	mock.Mock
}

func (*FakeDynamicClient) Create

func (*FakeDynamicClient) Get added in v0.5.0

func (*FakeDynamicClient) List

func (*FakeDynamicClient) Patch added in v0.9.0

func (c *FakeDynamicClient) Patch(name string, data []byte) (*unstructured.Unstructured, error)

func (*FakeDynamicClient) Watch

type FakeDynamicFactory

type FakeDynamicFactory struct {
	mock.Mock
}

func (*FakeDynamicFactory) ClientForGroupVersionResource

func (df *FakeDynamicFactory) ClientForGroupVersionResource(gv schema.GroupVersion, resource metav1.APIResource, namespace string) (client.Dynamic, error)

type FakeFileSystem added in v0.9.0

type FakeFileSystem struct {
	ReadDirCalls []string
	// contains filtered or unexported fields
}

func NewFakeFileSystem added in v0.9.0

func NewFakeFileSystem() *FakeFileSystem

func (*FakeFileSystem) Create added in v0.9.0

func (fs *FakeFileSystem) Create(name string) (io.WriteCloser, error)

func (*FakeFileSystem) DirExists added in v0.9.0

func (fs *FakeFileSystem) DirExists(path string) (bool, error)

func (*FakeFileSystem) MkdirAll added in v0.9.0

func (fs *FakeFileSystem) MkdirAll(path string, perm os.FileMode) error

func (*FakeFileSystem) ReadDir added in v0.9.0

func (fs *FakeFileSystem) ReadDir(dirname string) ([]os.FileInfo, error)

func (*FakeFileSystem) ReadFile added in v0.9.0

func (fs *FakeFileSystem) ReadFile(filename string) ([]byte, error)

func (*FakeFileSystem) RemoveAll added in v0.9.0

func (fs *FakeFileSystem) RemoveAll(path string) error

func (*FakeFileSystem) Stat added in v0.10.0

func (fs *FakeFileSystem) Stat(path string) (os.FileInfo, error)

func (*FakeFileSystem) TempDir added in v0.9.0

func (fs *FakeFileSystem) TempDir(dir, prefix string) (string, error)

func (*FakeFileSystem) TempFile added in v0.9.0

func (fs *FakeFileSystem) TempFile(dir, prefix string) (filesystem.NameWriteCloser, error)

func (*FakeFileSystem) WithDirectories added in v0.9.0

func (fs *FakeFileSystem) WithDirectories(path ...string) *FakeFileSystem

func (*FakeFileSystem) WithDirectory added in v0.9.0

func (fs *FakeFileSystem) WithDirectory(path string) *FakeFileSystem

func (*FakeFileSystem) WithFile added in v0.9.0

func (fs *FakeFileSystem) WithFile(path string, data []byte) *FakeFileSystem

func (*FakeFileSystem) WithFileAndMode added in v0.10.0

func (fs *FakeFileSystem) WithFileAndMode(path string, data []byte, mode os.FileMode) *FakeFileSystem

type FakeMapper

type FakeMapper struct {
	meta.RESTMapper
	AutoReturnResource bool
	Resources          map[schema.GroupVersionResource]schema.GroupVersionResource
}

func (*FakeMapper) ResourceFor

type FakeNamespaceClient added in v0.11.0

type FakeNamespaceClient struct {
	mock.Mock
}

func (*FakeNamespaceClient) Create added in v0.11.0

func (c *FakeNamespaceClient) Create(obj *v1.Namespace) (*v1.Namespace, error)

func (*FakeNamespaceClient) Delete added in v0.11.0

func (c *FakeNamespaceClient) Delete(name string, opts *metav1.DeleteOptions) error

func (*FakeNamespaceClient) Finalize added in v0.11.0

func (c *FakeNamespaceClient) Finalize(item *v1.Namespace) (*v1.Namespace, error)

func (*FakeNamespaceClient) Get added in v0.11.0

func (c *FakeNamespaceClient) Get(name string, opts metav1.GetOptions) (*v1.Namespace, error)

func (*FakeNamespaceClient) List added in v0.11.0

func (*FakeNamespaceClient) Patch added in v0.11.0

func (c *FakeNamespaceClient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*v1.Namespace, error)

func (*FakeNamespaceClient) Update added in v0.11.0

func (c *FakeNamespaceClient) Update(namespace *v1.Namespace) (*v1.Namespace, error)

func (*FakeNamespaceClient) UpdateStatus added in v0.11.0

func (c *FakeNamespaceClient) UpdateStatus(namespace *v1.Namespace) (*v1.Namespace, error)

func (*FakeNamespaceClient) Watch added in v0.11.0

type FakeServerResourcesInterface added in v1.0.0

type FakeServerResourcesInterface struct {
	ResourceList []*metav1.APIResourceList
	FailedGroups map[schema.GroupVersion]error
	ReturnError  error
}

func NewFakeServerResourcesInterface added in v1.0.0

func NewFakeServerResourcesInterface(resourceList []*metav1.APIResourceList, failedGroups map[schema.GroupVersion]error, returnError error) *FakeServerResourcesInterface

func (*FakeServerResourcesInterface) ServerPreferredResources added in v1.0.0

func (di *FakeServerResourcesInterface) ServerPreferredResources() ([]*metav1.APIResourceList, error)

type FakeVolumeSnapshotter added in v1.0.0

type FakeVolumeSnapshotter struct {
	// SnapshotID->VolumeID
	SnapshotsTaken sets.String

	// VolumeID -> (SnapshotID, Type, Iops)
	SnapshottableVolumes map[string]VolumeBackupInfo

	// VolumeBackupInfo -> VolumeID
	RestorableVolumes map[VolumeBackupInfo]string

	VolumeID    string
	VolumeIDSet string

	Error error
}

func (*FakeVolumeSnapshotter) CreateSnapshot added in v1.0.0

func (bs *FakeVolumeSnapshotter) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error)

func (*FakeVolumeSnapshotter) CreateVolumeFromSnapshot added in v1.0.0

func (bs *FakeVolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error)

func (*FakeVolumeSnapshotter) DeleteSnapshot added in v1.0.0

func (bs *FakeVolumeSnapshotter) DeleteSnapshot(snapshotID string) error

func (*FakeVolumeSnapshotter) GetVolumeID added in v1.0.0

func (bs *FakeVolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error)

func (*FakeVolumeSnapshotter) GetVolumeInfo added in v1.0.0

func (bs *FakeVolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error)

func (*FakeVolumeSnapshotter) Init added in v1.0.0

func (bs *FakeVolumeSnapshotter) Init(config map[string]string) error

func (*FakeVolumeSnapshotter) SetVolumeID added in v1.0.0

func (bs *FakeVolumeSnapshotter) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error)

type MockPodCommandExecutor added in v0.9.0

type MockPodCommandExecutor struct {
	mock.Mock
}

func (*MockPodCommandExecutor) ExecutePodCommand added in v0.9.0

func (e *MockPodCommandExecutor) ExecutePodCommand(log logrus.FieldLogger, item map[string]interface{}, namespace, name, hookName string, hook *v1.ExecHook) error

type VolumeBackupInfo added in v1.0.0

type VolumeBackupInfo struct {
	SnapshotID       string
	Type             string
	Iops             *int64
	AvailabilityZone string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL