Skip to content

Commit e74bb38

Browse files
committed
begin to add tests for storage/v1alpha
1 parent 262e57d commit e74bb38

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ run-unit-tests: $(GOBUILDDIR) $(SOURCES)
171171
golang:$(GOVERSION) \
172172
go test $(TESTVERBOSEOPTIONS) \
173173
$(REPOPATH)/pkg/apis/arangodb/v1alpha \
174+
$(REPOPATH)/pkg/apis/storage/v1alpha \
174175
$(REPOPATH)/pkg/deployment \
175176
$(REPOPATH)/pkg/util/k8sutil
176177

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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/stretchr/testify/assert"
29+
)
30+
31+
func Test_LocalStorageSpec_Creation(t *testing.T) {
32+
classSpec := StorageClassSpec{"the-spec-name", true}
33+
localSpec := LocalStorageSpec{StorageClass: classSpec, LocalPath: []string{"/blalala"}}
34+
35+
assert.Equal(t, nil, localSpec.Validate())
36+
assert.True(t, true)
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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/stretchr/testify/assert"
29+
)
30+
31+
func Test_ArangoLocalStorage_Creation(t *testing.T) {
32+
assert.True(t, true)
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
"strings"
27+
"testing"
28+
29+
"github.com/stretchr/testify/assert"
30+
)
31+
32+
func Test_StorageClassSpec_Creation(t *testing.T) {
33+
storageClassSpec := StorageClassSpec{}
34+
assert.True(t, nil != storageClassSpec.Validate())
35+
36+
storageClassSpec = StorageClassSpec{Name: "TheSpecName", IsDefault: true} // no upper-case allowed
37+
assert.True(t, nil != storageClassSpec.Validate())
38+
39+
storageClassSpec = StorageClassSpec{"the-spec-name", true}
40+
assert.Equal(t, nil, storageClassSpec.Validate())
41+
42+
storageClassSpec = StorageClassSpec{} // this is invalid because it was not created with a proper name
43+
storageClassSpec.SetDefaults("foo") // here the Name is fixed
44+
assert.Equal(t, nil, storageClassSpec.Validate())
45+
}
46+
47+
func Test_StorageClassSpec_ResetImmutableFileds(t *testing.T) {
48+
specSource := StorageClassSpec{"source", true}
49+
specTarget := StorageClassSpec{"target", true}
50+
51+
assert.Equal(t, "target", specTarget.Name)
52+
rv := specSource.ResetImmutableFields("fieldPrefix-", &specTarget)
53+
assert.Equal(t, "fieldPrefix-name", strings.Join(rv[:], ", "))
54+
assert.Equal(t, "source", specTarget.Name)
55+
}

0 commit comments

Comments
 (0)