Skip to content

Commit

Permalink
inline windows check
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
  • Loading branch information
Dave Henderson committed Aug 29, 2020
1 parent f6bb489 commit 611951c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 18 deletions.
3 changes: 1 addition & 2 deletions internal/tests/integration/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"bytes"
"io/ioutil"
"os"
"runtime"

. "gopkg.in/check.v1"

Expand Down Expand Up @@ -102,7 +101,7 @@ func (s *BasicSuite) TestRoutesInputsToProperOutputs(c *C) {
for _, v := range testdata {
info, err := os.Stat(v.path)
assert.NilError(c, err)
if runtime.GOOS != "windows" {
if !isWindows {
assert.Equal(c, v.mode, info.Mode())
}
content, err := ioutil.ReadFile(v.path)
Expand Down
7 changes: 3 additions & 4 deletions internal/tests/integration/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"bytes"
"io/ioutil"
"os"
"runtime"

"gopkg.in/check.v1"

Expand Down Expand Up @@ -155,7 +154,7 @@ func (s *ConfigSuite) TestEnvConfigFile(c *check.C) {
}

func (s *ConfigSuite) TestConfigOverridesEnvDelim(c *check.C) {
if runtime.GOOS != "windows" {
if !isWindows {
s.writeConfig(`inputFiles: [in]
leftDelim: (╯°□°)╯︵ ┻━┻
datasources:
Expand All @@ -173,7 +172,7 @@ datasources:
}

func (s *ConfigSuite) TestFlagOverridesAllDelim(c *check.C) {
if runtime.GOOS != "windows" {
if !isWindows {
s.writeConfig(`inputFiles: [in]
leftDelim: (╯°□°)╯︵ ┻━┻
datasources:
Expand All @@ -191,7 +190,7 @@ datasources:
}

func (s *ConfigSuite) TestConfigOverridesEnvPluginTimeout(c *check.C) {
if runtime.GOOS != "windows" {
if !isWindows {
s.writeConfig(`in: hi there {{ sleep 2 }}
plugins:
sleep: echo
Expand Down
3 changes: 1 addition & 2 deletions internal/tests/integration/datasources_env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package integration

import (
"os"
"runtime"

. "gopkg.in/check.v1"

Expand Down Expand Up @@ -36,7 +35,7 @@ func (s *EnvDatasourcesSuite) TestEnvDatasources(c *C) {
"-i", `{{ ds "foo" }}`,
)
// Windows envvars are case-insensitive
if runtime.GOOS == "windows" {
if isWindows {
result.Assert(c, icmd.Expected{ExitCode: 0, Out: "baz"})
} else {
result.Assert(c, icmd.Expected{ExitCode: 0, Out: "bar"})
Expand Down
3 changes: 1 addition & 2 deletions internal/tests/integration/datasources_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package integration
import (
"os"
"path/filepath"
"runtime"
"strconv"
"time"

Expand Down Expand Up @@ -98,7 +97,7 @@ func (s *GitDatasourcesSuite) TestGitFileDatasource(c *C) {
}

func (s *GitDatasourcesSuite) TestGitDatasource(c *C) {
if runtime.GOOS == "windows" {
if isWindows {
c.Skip("not going to run git daemon on Windows")
}
s.startGitDaemon()
Expand Down
9 changes: 4 additions & 5 deletions internal/tests/integration/inputdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package integration
import (
"io/ioutil"
"os"
"runtime"

. "gopkg.in/check.v1"

Expand Down Expand Up @@ -78,7 +77,7 @@ func (s *InputDirSuite) TestInputDir(c *C) {
info, err := os.Stat(v.path)
assert.NilError(c, err)
// chmod support on Windows is pretty weak for now
if runtime.GOOS != "windows" {
if !isWindows {
assert.Equal(c, v.mode, info.Mode(), v.path)
}
content, err := ioutil.ReadFile(v.path)
Expand Down Expand Up @@ -118,7 +117,7 @@ func (s *InputDirSuite) TestInputDirWithModeOverride(c *C) {
info, err := os.Stat(v.path)
assert.NilError(c, err)
// chmod support on Windows is pretty weak for now
if runtime.GOOS != "windows" {
if !isWindows {
assert.Equal(c, v.mode, info.Mode())
}
content, err := ioutil.ReadFile(v.path)
Expand Down Expand Up @@ -159,7 +158,7 @@ func (s *InputDirSuite) TestOutputMapInline(c *C) {
info, err := os.Stat(v.path)
assert.NilError(c, err)
// chmod support on Windows is pretty weak for now
if runtime.GOOS != "windows" {
if !isWindows {
assert.Equal(c, v.mode, info.Mode())
}
content, err := ioutil.ReadFile(v.path)
Expand Down Expand Up @@ -202,7 +201,7 @@ func (s *InputDirSuite) TestOutputMapExternal(c *C) {
info, err := os.Stat(v.path)
assert.NilError(c, err)
// chmod support on Windows is pretty weak for now
if runtime.GOOS != "windows" {
if !isWindows {
assert.Equal(c, v.mode, info.Mode())
}
content, err := ioutil.ReadFile(v.path)
Expand Down
4 changes: 3 additions & 1 deletion internal/tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ var (
GomplateBin string
)

const isWindows = runtime.GOOS == "windows"

// nolint: gochecknoinits
func init() {
ext := ""
if runtime.GOOS == "windows" {
if isWindows {
ext = ".exe"
}
GomplateBin = filepath.Join(build.Default.GOPATH, "src", "github.com", "hairyhenderson", "gomplate", "bin", "gomplate"+ext)
Expand Down
3 changes: 1 addition & 2 deletions internal/tests/integration/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package integration

import (
"runtime"
"time"

. "gopkg.in/check.v1"
Expand All @@ -20,7 +19,7 @@ func (s *TimeSuite) TestTime(c *C) {
inOutTest(c, `{{ (time.Parse "`+f+`" "`+i+`").Format "2006-01-02 15 -0700" }}`,
"2009-02-13 23 +0000")

if runtime.GOOS != "windows" {
if !isWindows {
result := icmd.RunCmd(icmd.Command(GomplateBin, "-i",
`{{ (time.ParseLocal time.Kitchen "6:00AM").Format "15:04 MST" }}`), func(cmd *icmd.Cmd) {
cmd.Env = []string{"TZ=Africa/Luanda"}
Expand Down

0 comments on commit 611951c

Please sign in to comment.