aboutsummaryrefslogtreecommitdiffstats
path: root/test/target_test.go
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-08-21 17:56:10 +0200
committerClément Bénier <clement.benier@iot.bzh>2018-08-21 17:56:10 +0200
commitb1d091a8c6b2269601a1683e963d0e382cd0f7f6 (patch)
treeec60f14ec47211e929d144bde128fbbff5f7c0dc /test/target_test.go
parent4192072863ac0997b0c3cb4131ea913e6f85f83e (diff)
test logs: hide log
logs are printable with VERBOSE != "" Change-Id: I170aed2e73db673ba6276410b1dddd3389239457 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
Diffstat (limited to 'test/target_test.go')
-rw-r--r--test/target_test.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/test/target_test.go b/test/target_test.go
index 50483ff..17ac6b8 100644
--- a/test/target_test.go
+++ b/test/target_test.go
@@ -111,7 +111,7 @@ func AddTargets(t *testing.T, nbTargets int, chTarget chan xsapiv1.TargetConfig)
}
/*add target*/
assert.Nil(t, HTTPCli.Post("/targets", target, &target))
- t.Logf("add target %v", target.Name)
+ Debugf(t, "add target %v", target.Name)
targetEvt := <-chTarget //waiting for event targetAdd
assert.Equal(t, target.ID, targetEvt.ID)
listID[i] = target.ID
@@ -134,7 +134,7 @@ func AddTerms(t *testing.T, nbTerms int, listID []string, chTermEvt chan xsapiv1
}
/*add terminal on target*/
assert.Nil(t, HTTPCli.Post("/targets/"+listID[j]+"/terminals", term, &term))
- t.Logf("add terminal %v", term.Name)
+ Debugf(t, "add terminal %v", term.Name)
termEvt := <-chTermEvt //waiting for event terminalAdd*/
assert.Equal(t, term.ID, termEvt.ID)
listTermsID[i] = term.ID
@@ -166,7 +166,7 @@ func PostTerms(t *testing.T, post string, chTermEvt chan xsapiv1.TerminalConfig)
var term xsapiv1.TerminalConfig
/*post action on term*/
assert.Nil(t, HTTPCli.Post("/targets/"+targets[i].ID+"/terminals/"+terms[j].ID+"/"+post, terms[j], &term))
- t.Logf("%v terminal %v", post, term.Name)
+ Debugf(t, "%v terminal %v", post, term.Name)
termEvt := <-chTermEvt //waiting for event terminalStateChange
assert.Equal(t, term.ID, termEvt.ID)
assert.Equal(t, term.Status, status)
@@ -178,7 +178,7 @@ func PostTerms(t *testing.T, post string, chTermEvt chan xsapiv1.TerminalConfig)
var term xsapiv1.TerminalConfig
assert.Nil(t, HTTPCli.Get("/targets/"+targets[i].ID+"/terminals/"+listTermsID[i], &term))
assert.True(t, strings.EqualFold(term.Status, post))
- t.Logf("check that term status %v is %v", term.Name, post)
+ Debugf(t, "check that term status %v is %v", term.Name, post)
}
}
}
@@ -195,7 +195,7 @@ func RemoveTermsTargets(t *testing.T, chTarget chan xsapiv1.TargetConfig, chTerm
termEvt := <-chTermEvt
assert.Equal(t, term.ID, termEvt.ID)
assert.NotNil(t, HTTPCli.Delete("/targets/"+targets[i].ID+"/terminals/"+terms[j].ID, &term))
- t.Logf("remove terminal %v", term.Name)
+ Debugf(t, "remove terminal %v", term.Name)
}
var tgtRes xsapiv1.TargetConfig
assert.Nil(t, HTTPCli.Delete("/targets/"+targets[i].ID, &tgtRes))
@@ -273,7 +273,7 @@ func TestTarget(t *testing.T) {
totoFileCurrent := totoFile + strconv.Itoa(i)
/*send cmd though term*/
data := []byte("echo helloWorld" + strconv.Itoa(i) + " >> " + totoFileCurrent + "\n")
- t.Logf("send following command through terminal: %v", string(data))
+ Debugf(t, "send following command through terminal: %v", string(data))
assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data))
flushChannelTerm(chTerm, 50) //waiting for terminal msg
@@ -283,7 +283,7 @@ func TestTarget(t *testing.T) {
/*send cmd though term*/
data = []byte("cat " + totoFileCurrent + "\n")
- t.Logf("send following command through terminal: %v", string(data))
+ Debugf(t, "send following command through terminal: %v", string(data))
assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data))
<-chTerm //cmd sent
@@ -291,7 +291,7 @@ func TestTarget(t *testing.T) {
flushChannelTerm(chTerm, 50) //flushing what remains
/*check that terminal msg is what was written before*/
assert.Equal(t, string(termOut.Stdout), "helloWorld"+strconv.Itoa(i)+"\r\n")
- t.Logf("check terminal output msg: %v", string(termOut.Stdout))
+ Debugf(t, "check terminal output msg: %v", string(termOut.Stdout))
}
PostTerms(t, "close", chTermEvt)
@@ -307,28 +307,28 @@ func TestTargetErrors(t *testing.T) {
target := xsapiv1.TargetConfig{}
var targetRes xsapiv1.TargetConfig
assert.NotNil(t, HTTPCli.Post("/targets", target, &targetRes))
- t.Logf("error while creating empty target")
+ Debugf(t, "error while creating empty target")
/*check cannot create target with no IP*/
target.Type = xsapiv1.TypeTgtStandard
assert.NotNil(t, HTTPCli.Post("/targets", target, &targetRes))
- t.Logf("error while creating target without IP")
+ Debugf(t, "error while creating target without IP")
target.IP = "127.0.0.1"
assert.Nil(t, HTTPCli.Post("/targets", target, &targetRes))
- t.Logf("create target %v", targetRes.Name)
+ Debugf(t, "create target %v", targetRes.Name)
/*cannot create empty terminal*/
term := xsapiv1.TerminalConfig{}
var termRes xsapiv1.TerminalConfig
assert.NotNil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes))
- t.Logf("error while creating empty terminal")
+ Debugf(t, "error while creating empty terminal")
term.Type = xsapiv1.TypeTermSSH
assert.NotNil(t, HTTPCli.Post("/targets/"+"1010"+"/terminals", term, &termRes))
- t.Logf("error while creating terminal on an non existing target")
+ Debugf(t, "error while creating terminal on an non existing target")
assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes))
assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes))
assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes))
assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes))
- t.Logf("create several terminals")
+ Debugf(t, "create several terminals")
/*remove targets and terms*/
var targetArray []xsapiv1.TargetConfig
@@ -338,15 +338,15 @@ func TestTargetErrors(t *testing.T) {
assert.Nil(t, HTTPCli.Get("/targets/"+targetArray[i].ID+"/terminals", &termArray))
for j := 0; j < len(termArray); j++ {
assert.Nil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID+"/terminals/"+termArray[j].ID, &termRes))
- t.Logf("delete terminal %v", termRes.Name)
+ Debugf(t, "delete terminal %v", termRes.Name)
assert.NotNil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID+"/terminals/"+termArray[j].ID, &termRes))
- t.Logf("error while deleting an already deleted terminal %v", termRes.Name)
+ Debugf(t, "error while deleting an already deleted terminal %v", termRes.Name)
}
var tgtRes xsapiv1.TargetConfig
assert.Nil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID, &tgtRes))
- t.Logf("delete target %v", tgtRes.Name)
+ Debugf(t, "delete target %v", tgtRes.Name)
assert.Equal(t, targetArray[i].ID, tgtRes.ID)
assert.NotNil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID, &tgtRes))
- t.Logf("error while deleting an already deleted target %v", tgtRes.Name)
+ Debugf(t, "error while deleting an already deleted target %v", tgtRes.Name)
}
}