|
| 1 | +// |
| 2 | +// DISCLAIMER |
| 3 | +// |
| 4 | +// Copyright 2018 ArangoDB GmbH, Cologne, Germany |
| 5 | +// |
| 6 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | +// |
| 18 | +// Copyright holder is ArangoDB GmbH, Cologne, Germany |
| 19 | +// |
| 20 | +// Author Jan Christoph Uhde |
| 21 | +// |
| 22 | + |
| 23 | +package v1alpha |
| 24 | + |
| 25 | +import ( |
| 26 | + "testing" |
| 27 | + |
| 28 | + //"github.com/pkg/errors" |
| 29 | + "github.com/stretchr/testify/assert" |
| 30 | +) |
| 31 | + |
| 32 | +// Test creation of local storage spec |
| 33 | +func TestLocalStorageSpecCreation(t *testing.T) { |
| 34 | + |
| 35 | + class := StorageClassSpec{"SpecName", true} |
| 36 | + local := LocalStorageSpec{StorageClass: class, LocalPath: []string{""}} |
| 37 | + assert.Error(t, local.Validate()) |
| 38 | + |
| 39 | + class = StorageClassSpec{"spec-name", true} |
| 40 | + local = LocalStorageSpec{StorageClass: class, LocalPath: []string{""}} |
| 41 | + assert.Error(t, local.Validate(), "should fail as the empty sting is not a valid path") |
| 42 | + |
| 43 | + class = StorageClassSpec{"spec-name", true} |
| 44 | + local = LocalStorageSpec{StorageClass: class, LocalPath: []string{}} |
| 45 | + assert.True(t, IsValidation(local.Validate())) |
| 46 | +} |
| 47 | + |
| 48 | +// Test reset of local storage spec |
| 49 | +func TestLocalStorageSpecReset(t *testing.T) { |
| 50 | + class := StorageClassSpec{"spec-name", true} |
| 51 | + source := LocalStorageSpec{StorageClass: class, LocalPath: []string{"/a/path", "/another/path"}} |
| 52 | + target := LocalStorageSpec{} |
| 53 | + resetImmutableFieldsResult := source.ResetImmutableFields(&target) |
| 54 | + expected := []string{"storageClass.name", "localPath"} |
| 55 | + assert.Equal(t, expected, resetImmutableFieldsResult) |
| 56 | + assert.Equal(t, source.LocalPath, target.LocalPath) |
| 57 | + assert.Equal(t, source.StorageClass.Name, target.StorageClass.Name) |
| 58 | +} |
0 commit comments