-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathoptions_test.go
40 lines (34 loc) · 915 Bytes
/
options_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package envbuilder_test
import (
"testing"
"github.com/coder/envbuilder"
"github.com/coder/serpent"
"github.com/stretchr/testify/require"
)
type testEnvCase struct {
Env string
EnvValue string
Expected interface{}
Actual func() interface{}
}
func TestEnvOptions(t *testing.T) {
t.Setenv("SETUP_SCRIPT", "setup.sh")
t.Setenv("CACHE_TTL_DAYS", "7")
t.Setenv("IGNORE_PATHS", "/var,/tmp")
t.Setenv("SKIP_REBUILD", "true")
t.Setenv("GIT_CLONE_SINGLE_BRANCH", "")
var o = envbuilder.Options{}
cmd := serpent.Command{
Options: o.CLI(),
Handler: func(inv *serpent.Invocation) error {
return nil
},
}
err := cmd.Invoke().WithOS().Run()
require.NoError(t, err)
require.Equal(t, o.SetupScript, "setup.sh")
require.Equal(t, o.CacheTTLDays, int64(7))
require.Equal(t, o.IgnorePaths, []string{"/var", "/tmp"})
require.True(t, o.SkipRebuild)
require.False(t, o.GitCloneSingleBranch)
}