mirror of https://github.com/helm/helm
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>pull/5365/head
parent
f185103b60
commit
f8ed917830
@ -0,0 +1,103 @@
|
||||
/*
|
||||
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 main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/helm/pkg/release"
|
||||
)
|
||||
|
||||
const mockTestSuccessTemplate = `apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
annotations:
|
||||
"helm.sh/hook": test-success
|
||||
`
|
||||
|
||||
func TestReleaseTesting(t *testing.T) {
|
||||
timestamp := time.Unix(1452902400, 0).UTC()
|
||||
|
||||
tests := []cmdTestCase{{
|
||||
name: "successful test",
|
||||
cmd: "status test-success",
|
||||
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{
|
||||
Name: "test-success",
|
||||
TestSuiteResults: []*release.TestRun{
|
||||
{
|
||||
Name: "test-success",
|
||||
Status: release.TestRunSuccess,
|
||||
StartedAt: timestamp,
|
||||
CompletedAt: timestamp,
|
||||
},
|
||||
},
|
||||
})},
|
||||
golden: "output/test-success.txt",
|
||||
}, {
|
||||
name: "test failure",
|
||||
cmd: "status test-failure",
|
||||
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{
|
||||
Name: "test-failure",
|
||||
TestSuiteResults: []*release.TestRun{
|
||||
{
|
||||
Name: "test-failure",
|
||||
Status: release.TestRunFailure,
|
||||
StartedAt: timestamp,
|
||||
CompletedAt: timestamp,
|
||||
},
|
||||
},
|
||||
})},
|
||||
golden: "output/test-failure.txt",
|
||||
}, {
|
||||
name: "test unknown",
|
||||
cmd: "status test-unknown",
|
||||
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{
|
||||
Name: "test-unknown",
|
||||
TestSuiteResults: []*release.TestRun{
|
||||
{
|
||||
Name: "test-unknown",
|
||||
Status: release.TestRunUnknown,
|
||||
StartedAt: timestamp,
|
||||
CompletedAt: timestamp,
|
||||
},
|
||||
},
|
||||
})},
|
||||
golden: "output/test-unknown.txt",
|
||||
}, {
|
||||
name: "test running",
|
||||
cmd: "status test-running",
|
||||
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{
|
||||
Name: "test-running",
|
||||
TestSuiteResults: []*release.TestRun{
|
||||
{
|
||||
Name: "test-running",
|
||||
Status: release.TestRunRunning,
|
||||
StartedAt: timestamp,
|
||||
CompletedAt: timestamp,
|
||||
},
|
||||
},
|
||||
})},
|
||||
golden: "output/test-running.txt",
|
||||
}, {
|
||||
name: "test with no tests",
|
||||
cmd: "test no-tests",
|
||||
rels: []*release.Release{release.Mock(&release.MockReleaseOptions{Name: "no-tests"})},
|
||||
golden: "output/test-no-tests.txt",
|
||||
}}
|
||||
runTestCmd(t, tests)
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
NAME: test-failure
|
||||
LAST DEPLOYED: 1977-09-02 22:04:05 +0000 UTC
|
||||
NAMESPACE: default
|
||||
STATUS: deployed
|
||||
|
||||
TEST SUITE:
|
||||
Last Started: 1977-09-02 22:04:05 +0000 UTC
|
||||
Last Completed: 1977-09-02 22:04:05 +0000 UTC
|
||||
|
||||
TEST STATUS INFO STARTED COMPLETED
|
||||
test-failure failure 2016-01-16 00:00:00 +0000 UTC 2016-01-16 00:00:00 +0000 UTC
|
@ -0,0 +1 @@
|
||||
No Tests Found
|
@ -0,0 +1,11 @@
|
||||
NAME: test-running
|
||||
LAST DEPLOYED: 1977-09-02 22:04:05 +0000 UTC
|
||||
NAMESPACE: default
|
||||
STATUS: deployed
|
||||
|
||||
TEST SUITE:
|
||||
Last Started: 1977-09-02 22:04:05 +0000 UTC
|
||||
Last Completed: 1977-09-02 22:04:05 +0000 UTC
|
||||
|
||||
TEST STATUS INFO STARTED COMPLETED
|
||||
test-running running 2016-01-16 00:00:00 +0000 UTC 2016-01-16 00:00:00 +0000 UTC
|
@ -0,0 +1,11 @@
|
||||
NAME: test-success
|
||||
LAST DEPLOYED: 1977-09-02 22:04:05 +0000 UTC
|
||||
NAMESPACE: default
|
||||
STATUS: deployed
|
||||
|
||||
TEST SUITE:
|
||||
Last Started: 1977-09-02 22:04:05 +0000 UTC
|
||||
Last Completed: 1977-09-02 22:04:05 +0000 UTC
|
||||
|
||||
TEST STATUS INFO STARTED COMPLETED
|
||||
test-success success 2016-01-16 00:00:00 +0000 UTC 2016-01-16 00:00:00 +0000 UTC
|
@ -0,0 +1,11 @@
|
||||
NAME: test-unknown
|
||||
LAST DEPLOYED: 1977-09-02 22:04:05 +0000 UTC
|
||||
NAMESPACE: default
|
||||
STATUS: deployed
|
||||
|
||||
TEST SUITE:
|
||||
Last Started: 1977-09-02 22:04:05 +0000 UTC
|
||||
Last Completed: 1977-09-02 22:04:05 +0000 UTC
|
||||
|
||||
TEST STATUS INFO STARTED COMPLETED
|
||||
test-unknown unknown 2016-01-16 00:00:00 +0000 UTC 2016-01-16 00:00:00 +0000 UTC
|
Loading…
Reference in new issue