mirror of https://github.com/helm/helm
Signed-off-by: Simon Alling <alling.simon@gmail.com>pull/10573/head
parent
c137bfb68b
commit
26da3dcc1b
@ -0,0 +1,14 @@
|
||||
NAME: doge
|
||||
LAST DEPLOYED: Fri Sep 2 22:04:05 1977
|
||||
NAMESPACE: default
|
||||
STATUS: deployed
|
||||
REVISION: 1
|
||||
TEST SUITE: doge-test-pod
|
||||
Last Started: Fri Apr 16 13:37:00 2021
|
||||
Last Completed: Fri Apr 16 14:00:00 2021
|
||||
Phase: Succeeded
|
||||
NOTES:
|
||||
Some mock release notes!
|
||||
|
||||
POD LOGS: doge-test-pod
|
||||
example test pod log output
|
@ -0,0 +1,11 @@
|
||||
NAME: doge
|
||||
LAST DEPLOYED: Fri Sep 2 22:04:05 1977
|
||||
NAMESPACE: default
|
||||
STATUS: deployed
|
||||
REVISION: 1
|
||||
TEST SUITE: doge-test-pod
|
||||
Last Started: Fri Apr 16 13:37:00 2021
|
||||
Last Completed: Fri Apr 16 14:00:00 2021
|
||||
Phase: Succeeded
|
||||
NOTES:
|
||||
Some mock release notes!
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright The Helm 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 action
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"helm.sh/helm/v3/pkg/release"
|
||||
)
|
||||
|
||||
func releaseTestingAction(t *testing.T) *ReleaseTesting {
|
||||
config := actionConfigFixture(t)
|
||||
testAction := NewReleaseTesting(config)
|
||||
return testAction
|
||||
}
|
||||
|
||||
func TestReleaseTesting(t *testing.T) {
|
||||
is := assert.New(t)
|
||||
|
||||
testAction := releaseTestingAction(t)
|
||||
|
||||
rel := releaseStub()
|
||||
testAction.cfg.Releases.Create(rel)
|
||||
expectedConfigMapHook := release.Hook{
|
||||
Name: "test-cm",
|
||||
Kind: "ConfigMap",
|
||||
Path: "test-cm",
|
||||
LastRun: release.HookExecution{
|
||||
Phase: "",
|
||||
},
|
||||
}
|
||||
expectedPodHook := release.Hook{
|
||||
Name: "finding-nemo",
|
||||
Kind: "Pod",
|
||||
Path: "finding-nemo",
|
||||
LastRun: release.HookExecution{
|
||||
Phase: "Succeeded",
|
||||
},
|
||||
}
|
||||
res, err := testAction.Run(rel.Name)
|
||||
is.NoError(err)
|
||||
is.Equal("angry-panda", res.Name)
|
||||
is.Len(res.Hooks, 2, "The action seems to have changed the number of hooks on the release.")
|
||||
checkHook(t, expectedConfigMapHook, res.Hooks[0])
|
||||
checkHook(t, expectedPodHook, res.Hooks[1])
|
||||
}
|
||||
|
||||
func checkHook(t *testing.T, expected release.Hook, actual *release.Hook) {
|
||||
t.Helper()
|
||||
is := assert.New(t)
|
||||
is.Equal(expected.Name, actual.Name)
|
||||
is.Equal(expected.Kind, actual.Kind)
|
||||
is.Equal(expected.Path, actual.Path)
|
||||
is.Equal(expected.LastRun.Phase, actual.LastRun.Phase)
|
||||
// Cannot expect start and completion times because they cannot be predicted.
|
||||
}
|
Loading…
Reference in new issue