grim/convey
Clone
Summary
Browse
Changes
Graph
Another typo fix
2018-01-14, Gary Kramlich
309efdf0a7b1
Another typo fix
// 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
bitbucket
import
(
"github.com/aphistic/sweet"
"github.com/go-yaml/yaml"
.
"github.com/onsi/gomega"
)
func
(
b
*
bitbucketSuite
)
TestUnmarshalSimple
(
t
sweet
.
T
)
{
yamlData
:=
`image: python:3
pipelines:
default:
- step:
script:
- set -ex
- find . -type f -iname "*.pyc" -exec rm -f {} \; || true
- find . -type d -iname __pycache__ -exec rm -rf {} \; || true
- pip install -r dev-requirements.txt
- flake8
- PYTHONPATH=$(pwd) py.test --color=auto --cov=pipelines --cov-report=term-missing tests`
var
actual
bitbucketPipelines
err
:=
yaml
.
Unmarshal
([]
byte
(
yamlData
),
&
actual
)
Expect
(
err
).
To
(
BeNil
())
expected
:=
bitbucketPipelines
{
Image
:
image
{
Name
:
"python:3"
,
},
Pipelines
:
pipelines
{
Default
:
[]
pipeline
{
{
Steps
:
step
{
Script
:
[]
string
{
"set -ex"
,
"find . -type f -iname \"*.pyc\" -exec rm -f {} \\; || true"
,
"find . -type d -iname __pycache__ -exec rm -rf {} \\; || true"
,
"pip install -r dev-requirements.txt"
,
"flake8"
,
"PYTHONPATH=$(pwd) py.test --color=auto --cov=pipelines --cov-report=term-missing tests"
,
},
},
},
},
},
}
Expect
(
actual
).
To
(
Equal
(
expected
))
}
func
(
b
*
bitbucketSuite
)
TestUnmarshalMultipleBranches
(
t
sweet
.
T
)
{
yamlData
:=
`image: pidgin/builder-debian:stretch
pipelines:
default:
- step:
script:
- set -ex
- ./autogen.sh --enable-debug --enable-gtk-doc
- make -s -j$(nproc)
- make -s -j$(nproc) distcheck
branches:
release-2.x.y:
- step:
image: pidgin/release-builder:release-2.x.y
script:
- set -ex
- ./autogen.sh --enable-debug
- make -s -j$(nproc)
- make -s -j$(nproc) check
- make distcheck`
var
actual
bitbucketPipelines
err
:=
yaml
.
Unmarshal
([]
byte
(
yamlData
),
&
actual
)
Expect
(
err
).
To
(
BeNil
())
expected
:=
bitbucketPipelines
{
Image
:
image
{
Name
:
"pidgin/builder-debian:stretch"
,
},
Pipelines
:
pipelines
{
Default
:
[]
pipeline
{
{
Steps
:
step
{
Script
:
[]
string
{
"set -ex"
,
"./autogen.sh --enable-debug --enable-gtk-doc"
,
"make -s -j$(nproc)"
,
"make -s -j$(nproc) distcheck"
,
},
},
},
},
Branches
:
map
[
string
][]
pipeline
{
"release-2.x.y"
:
{
{
Steps
:
step
{
Image
:
image
{
Name
:
"pidgin/release-builder:release-2.x.y"
,
},
Script
:
[]
string
{
"set -ex"
,
"./autogen.sh --enable-debug"
,
"make -s -j$(nproc)"
,
"make -s -j$(nproc) check"
,
"make distcheck"
,
},
},
},
},
},
},
}
Expect
(
actual
).
To
(
Equal
(
expected
))
}
func
(
b
*
bitbucketSuite
)
TestUnmarshalWithDocker
(
t
sweet
.
T
)
{
yamlData
:=
`pipelines:
default:
- step:
script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker build -t atlassian/my-app:$BITBUCKET_COMMIT .
- docker push atlassian/my-app:$BITBUCKET_COMMIT
options:
docker: true
`
var
actual
bitbucketPipelines
err
:=
yaml
.
Unmarshal
([]
byte
(
yamlData
),
&
actual
)
Expect
(
err
).
To
(
BeNil
())
expected
:=
bitbucketPipelines
{
Pipelines
:
pipelines
{
Default
:
[]
pipeline
{
{
Steps
:
step
{
Script
:
[]
string
{
"docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD"
,
"docker build -t atlassian/my-app:$BITBUCKET_COMMIT ."
,
"docker push atlassian/my-app:$BITBUCKET_COMMIT"
,
},
},
},
},
},
Options
:
options
{
Docker
:
true
,
},
}
Expect
(
actual
).
To
(
Equal
(
expected
))
}
func
(
b
*
bitbucketSuite
)
TestUnmarshalComplexGlobalImage
(
t
sweet
.
T
)
{
yamlData
:=
`pipelines:
image:
name: foobar
pipelines:
default:
- step:
script:
- true
`
var
actual
bitbucketPipelines
err
:=
yaml
.
Unmarshal
([]
byte
(
yamlData
),
&
actual
)
Expect
(
err
).
To
(
BeNil
())
expected
:=
bitbucketPipelines
{
Image
:
image
{
Name
:
"foobar"
,
},
Pipelines
:
pipelines
{
Default
:
[]
pipeline
{
{
Steps
:
step
{
Script
:
[]
string
{
"true"
,
},
},
},
},
},
}
Expect
(
actual
).
To
(
Equal
(
expected
))
}
func
(
b
*
bitbucketSuite
)
TestUnmarshalComplexStepImage
(
t
sweet
.
T
)
{
yamlData
:=
`pipelines:
pipelines:
default:
- step:
image:
name: name
username: user
password: pass
email: test@example.com
script:
- true
`
var
actual
bitbucketPipelines
err
:=
yaml
.
Unmarshal
([]
byte
(
yamlData
),
&
actual
)
Expect
(
err
).
To
(
BeNil
())
expected
:=
bitbucketPipelines
{
Pipelines
:
pipelines
{
Default
:
[]
pipeline
{
{
Steps
:
step
{
Image
:
image
{
Name
:
"name"
,
Username
:
"user"
,
Password
:
"pass"
,
EMail
:
"test@example.com"
,
},
Script
:
[]
string
{
"true"
,
},
},
},
},
},
}
Expect
(
actual
).
To
(
Equal
(
expected
))
}