grim/convey
Clone
Summary
Browse
Changes
Graph
Add environment support to metaplans. Fixes CONVEY-185
2021-12-23, Gary Kramlich
9d2745690a29
Add environment support to metaplans. Fixes CONVEY-185
// Convey
// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package
runtime
import
(
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
)
func
TestUnmarshalDefaults
(
t
*
testing
.
T
)
{
// we need a non empty string to get go-yaml to call our UnmarshalYAML
// function
data
:=
`name: foo`
var
stage
Stage
err
:=
yaml
.
Unmarshal
([]
byte
(
data
),
&
stage
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
stage
.
Run
,
"on-success"
)
}
func
TestUnmarshalInvalidRun
(
t
*
testing
.
T
)
{
data
:=
`run: invalid`
var
stage
Stage
err
:=
yaml
.
Unmarshal
([]
byte
(
data
),
&
stage
)
assert
.
NotNil
(
t
,
err
)
}
func
TestUnmarshalRunOnSuccess
(
t
*
testing
.
T
)
{
data
:=
`run: on-success`
var
stage
Stage
err
:=
yaml
.
Unmarshal
([]
byte
(
data
),
&
stage
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
stage
.
Run
,
"on-success"
)
}
func
TestUnmarshalRunOnFailure
(
t
*
testing
.
T
)
{
data
:=
`run: on-failure`
var
stage
Stage
err
:=
yaml
.
Unmarshal
([]
byte
(
data
),
&
stage
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
stage
.
Run
,
"on-failure"
)
}
func
TestUnmarshalRunAlways
(
t
*
testing
.
T
)
{
data
:=
`run: always`
var
stage
Stage
err
:=
yaml
.
Unmarshal
([]
byte
(
data
),
&
stage
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
stage
.
Run
,
"always"
)
}