* 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/>. "bitbucket.org/rw_grim/convey/environment" "bitbucket.org/rw_grim/convey/state" "bitbucket.org/rw_grim/convey/tasks" "github.com/aphistic/gomol" "github.com/aphistic/sweet" . "github.com/onsi/gomega" func (s *intrinsicSuite) TestExtendExecute(t sweet.T) { st = &state.State{Environment: []string{"bar=bonk", "quux=honk"}} task.executeFn = func(name string, logger *gomol.LogAdapter, env []string, st *state.State) error { fullEnv = environment.Merge(environment.Merge(env, []string{"x=1", "foo=quux"}), st.Environment) Environment: []string{"foo=bar", "bar=baz"}, Expect(c.Execute("task", nil, nil, st)).To(BeNil()) Expect(fullEnv).To(HaveLen(4)) Expect(fullEnv).To(ConsistOf("x=1", "foo=bar", "bar=bonk", "quux=honk")) Expect(st.Environment).To(HaveLen(2)) Expect(st.Environment).To(ConsistOf("bar=bonk", "quux=honk")) func (s *intrinsicSuite) TestDependencies(t sweet.T) { c := &Extend{Task: "test-task"} Expect(c.Dependencies()).To(Equal([]string{"test-task"})) func (s *intrinsicSuite) TestResolve(t sweet.T) { task.Y = []string{"foo", "bar"} err := c.Resolve(map[string]tasks.Task{ Expect(c.InnerTask).NotTo(BeNil()) Expect(c.InnerTask).NotTo(BeIdenticalTo(task)) Expect(c.InnerTask.(*mockTask).X).To(Equal(3)) Expect(c.InnerTask.(*mockTask).Y).To(Equal([]string{"foo", "bar"})) Expect(c.InnerTask.(*mockTask).Z.A).To(Equal("wynken")) Expect(c.InnerTask.(*mockTask).Z.B).To(Equal("blynken")) Expect(c.InnerTask.(*mockTask).Z.C).To(Equal("nod")) func (s *intrinsicSuite) TestResolveChain(t sweet.T) { task.Y = []string{"foo", "bar"} taskMapping := map[string]tasks.Task{ Expect(c1.Resolve(taskMapping)).To(BeNil()) Expect(c2.Resolve(taskMapping)).To(BeNil()) Expect(c2.InnerTask).NotTo(BeNil()) Expect(c2.InnerTask).NotTo(BeIdenticalTo(c1)) Expect(c2.InnerTask.(*Extend).InnerTask).NotTo(BeNil()) Expect(c2.InnerTask.(*Extend).InnerTask.(*mockTask).X).To(Equal(3)) Expect(c2.InnerTask.(*Extend).InnerTask.(*mockTask).Y).To(Equal([]string{"foo", "bar"})) executeFn func(string, *gomol.LogAdapter, []string, *state.State) error func newMockTask() *mockTask { executeFn: func(string, *gomol.LogAdapter, []string, *state.State) error { func (t *mockTask) Execute(name string, logger *gomol.LogAdapter, env []string, st *state.State) error { return t.executeFn(name, logger, env, st) func (t *mockTask) New() tasks.Task { func (t *mockTask) Valid() error {