grim/convey

closing merged branch
expand-list
2017-10-03, Gary Kramlich
345a52ef04c6
closing merged branch
/*
* Convey
* Copyright 2016-2017 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 docker
import (
"github.com/aphistic/sweet"
. "github.com/onsi/gomega"
cYaml "bitbucket.org/rw_grim/convey/yaml"
)
func (s *dockerSuite) TestTag(t sweet.T) {
p1 := &Tag{
Source: "source",
Destination: "destination",
}
Expect(p1.Valid()).To(BeNil())
p2 := &Tag{
Source: "source",
Destinations: cYaml.StringOrSlice{"dest1", "dest2", "dest3"},
}
Expect(p2.Valid()).To(BeNil())
}
func (s *dockerSuite) TestTagSourceRequired(t sweet.T) {
tag := &Tag{
Destination: "destination",
}
Expect(tag.Valid()).To(MatchError(errNoSourceTag))
}
func (s *dockerSuite) TestTagDestinationRequired(t sweet.T) {
p1 := &Tag{
Source: "source",
}
Expect(p1.Valid()).To(MatchError(errNoDestinationTags))
p2 := &Tag{
Source: "source",
Destinations: cYaml.StringOrSlice{},
}
Expect(p2.Valid()).To(MatchError(errNoDestinationTags))
}
func (s *dockerSuite) TestTagValidNormalizesDestinations(t sweet.T) {
p := &Tag{
Source: "source",
Destination: "dest1",
Destinations: cYaml.StringOrSlice{"dest2", "dest3"},
}
p.Valid()
Expect(p.Destinations).To(Equal(cYaml.StringOrSlice{"dest1", "dest2", "dest3"}))
}