|
| 1 | +// |
| 2 | +// DISCLAIMER |
| 3 | +// |
| 4 | +// Copyright 2016-2022 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 | + |
| 21 | +package deployment |
| 22 | + |
| 23 | +import ( |
| 24 | + "context" |
| 25 | + "testing" |
| 26 | + |
| 27 | + "github.com/stretchr/testify/require" |
| 28 | + meta "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 29 | + |
| 30 | + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" |
| 31 | +) |
| 32 | + |
| 33 | +func Test_SpecAccept_Initial(t *testing.T) { |
| 34 | + spec := api.DeploymentSpec{} |
| 35 | + |
| 36 | + spec.SetDefaults(testDeploymentName) |
| 37 | + |
| 38 | + depl := &api.ArangoDeployment{ |
| 39 | + ObjectMeta: meta.ObjectMeta{ |
| 40 | + Name: testDeploymentName, |
| 41 | + }, |
| 42 | + Spec: spec, |
| 43 | + Status: api.DeploymentStatus{ |
| 44 | + AcceptedSpec: spec.DeepCopy(), |
| 45 | + }, |
| 46 | + } |
| 47 | + |
| 48 | + d, _ := createTestDeployment(t, Config{}, depl) |
| 49 | + |
| 50 | + if _, err := d.deps.Client.Arango().DatabaseV1().ArangoDeployments(testNamespace).Create(context.Background(), depl, meta.CreateOptions{}); err != nil { |
| 51 | + require.NoError(t, err) |
| 52 | + } |
| 53 | + |
| 54 | + _, _, err := d.acceptNewSpec(context.Background(), depl) |
| 55 | + require.NoError(t, err) |
| 56 | + |
| 57 | + depl, err = d.deps.Client.Arango().DatabaseV1().ArangoDeployments(testNamespace).Get(context.Background(), testDeploymentName, meta.GetOptions{}) |
| 58 | + require.NoError(t, err) |
| 59 | + |
| 60 | + checksum, err := spec.Checksum() |
| 61 | + require.NoError(t, err) |
| 62 | + |
| 63 | + require.NotNil(t, depl.Status.AcceptedSpecVersion) |
| 64 | + require.Equal(t, checksum, *depl.Status.AcceptedSpecVersion) |
| 65 | +} |
0 commit comments