Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
pior committed Feb 20, 2022
1 parent d0c808d commit 9de7783
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@ commands:
desc: Build all bud binaries
run: script/buildall

poipoi: echo $POIPOI

env: env | sort

open:
milestone: https://github.com/devbuddy/devbuddy/milestone/1
10 changes: 10 additions & 0 deletions tests/cmd_custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ func Test_Cmd_Custom_Short_Syntax(t *testing.T) {
OutputEqual(t, lines, "🐼 running touch somefile")
}

func Test_Cmd_Custom_Envs_Are_Applied(t *testing.T) {
c := CreateContextAndInit(t)

project := CreateProject(c, "project", `{env: {MYVAR: poipoi}, commands: {mycmd: "echo __${MYVAR}__ > result"}}`)
c.Cd(project.Path)

c.Run("bud mycmd")
c.AssertContains("result", "__poipoi__")
}

func Test_Cmd_Custom_Always_Run_In_Project_Root(t *testing.T) {
c := CreateContextAndInit(t)

Expand Down
5 changes: 5 additions & 0 deletions tests/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ func (e *TestContext) AssertExist(path string) {
require.NoError(e.t, err, "expected file %s to exist", quotedPath)
}

func (e *TestContext) AssertContains(path, expected string) {
value := e.Cat(path)
require.Equal(e.t, expected, value, "expected file %s to exist", strconv.Quote(path))
}

func (e *TestContext) GetEnv(name string) string {
lines, err := e.shell.Run("echo ${" + name + "}")
require.NoError(e.t, err)
Expand Down

0 comments on commit 9de7783

Please sign in to comment.