summaryrefslogtreecommitdiffstats
path: root/test/exec_test.go
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-10-23 15:09:06 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2018-10-24 10:43:37 +0000
commita740425411f120ff7263f16f268e7efd7c19b311 (patch)
tree4ef142dfb4b5c57648e4e00243a234b2ad31f086 /test/exec_test.go
parent3e3222406a6f015a9fee3720e8ba76ecf58b087f (diff)
testify: assert replace by require
require handles tests to be aborted during an assertion contrary to assert Change-Id: I3062046515c74509ae7ea1b24b7242a42d0191c1 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
Diffstat (limited to 'test/exec_test.go')
-rw-r--r--test/exec_test.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/test/exec_test.go b/test/exec_test.go
index 39f00c6..6ffc350 100644
--- a/test/exec_test.go
+++ b/test/exec_test.go
@@ -24,7 +24,7 @@ import (
"testing"
"gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1"
- "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
func InitExec(t *testing.T) string {
@@ -34,14 +34,14 @@ func InitExec(t *testing.T) string {
cmd := exec.Command("cp", "-r", helloworldFixturesDir, helloworldDir)
var out bytes.Buffer
cmd.Stdout = &out
- assert.Nil(t, cmd.Run())
+ require.Nil(t, cmd.Run())
/*clone submodules app templates into helloworld*/
subHelloworldAppTemplateDir := path.Join(helloworldDir, "conf.d", "app-templates")
cmd = exec.Command("git", "clone", "-b", "flounder",
"https://gerrit.automotivelinux.org/gerrit/p/apps/app-templates.git",
subHelloworldAppTemplateDir)
- assert.Nil(t, cmd.Run())
+ require.Nil(t, cmd.Run())
return helloworldDir
}
@@ -60,8 +60,8 @@ func TestExec(t *testing.T) {
/*check there is no project*/
var cfgArray []xsapiv1.FolderConfig
- assert.Nil(t, HTTPCli.Get("/folders", &cfgArray))
- assert.Equal(t, len(cfgArray), 0)
+ require.Nil(t, HTTPCli.Get("/folders", &cfgArray))
+ require.Equal(t, len(cfgArray), 0)
fPrj := xsapiv1.FolderConfig{
Label: "testproject",
@@ -74,8 +74,8 @@ func TestExec(t *testing.T) {
}
/*create project*/
var cfg xsapiv1.FolderConfig
- assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg))
- assert.NotNil(t, cfg)
+ require.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg))
+ require.NotNil(t, cfg)
/*channel for ExecExitMsg*/
chExec := make(chan xsapiv1.ExecExitMsg)
@@ -99,7 +99,7 @@ func TestExec(t *testing.T) {
}
Debugf(t, "exec cmake cmd(%v)", cmd)
cmdOut = ""
- assert.NotNil(t, HTTPCli.Post("/exec", exec, &execRes))
+ require.NotNil(t, HTTPCli.Post("/exec", exec, &execRes))
/*basic check: verify that environment is set correctly (use the right sdk)*/
cmd = "pwd && echo \"SDKTARGETSYSROOT=<$SDKTARGETSYSROOT>\""
@@ -110,9 +110,9 @@ func TestExec(t *testing.T) {
}
Debugf(t, "exec cmake cmd(%v)", cmd)
cmdOut = ""
- assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
+ require.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
exitMsg := <-chExec
- assert.Equal(t, exitMsg.Code, 0)
+ require.Equal(t, exitMsg.Code, 0)
/*cmake helloworld project with fake sdk*/
cmd = "cd " + fPrj.ClientPath
@@ -129,9 +129,9 @@ func TestExec(t *testing.T) {
Cmd: cmd,
}
Debugf(t, "exec cmake cmd(%v)", cmd)
- assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
+ require.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
exitMsg = <-chExec
- assert.Equal(t, exitMsg.Code, 0)
+ require.Equal(t, exitMsg.Code, 0)
/*make helloworld project with fake sdk*/
cmd = "cd " + fPrj.ClientPath
@@ -142,17 +142,17 @@ func TestExec(t *testing.T) {
exec.Cmd = cmd
/*post exec cmd make*/
Debugf(t, "exec make cmd(%v)", cmd)
- assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
+ require.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
exitMsg = <-chExec
- assert.Equal(t, exitMsg.Code, 0)
+ require.Equal(t, exitMsg.Code, 0)
/*check if helloworld.so exists*/
Debug(t, "check that helloworld.so exists")
_, err := os.Stat(path.Join(fPrj.ClientPath, "build/helloworld/helloworld.so"))
- assert.Nil(t, err)
+ require.Nil(t, err)
/*deinit*/
- assert.Nil(t, HTTPCli.Delete("/folders/"+cfg.ID, &cfg))
+ require.Nil(t, HTTPCli.Delete("/folders/"+cfg.ID, &cfg))
RemoveSdk(t, sdkRes, chSdks)
DisconnectSDKStateChange(t, sCli)
}