Procházet zdrojové kódy

changing crmSite in one test case has side effect for other testcases...

master
Patrick Peng Sun před 8 roky
rodič
revize
e4929b74fb
1 změnil soubory, kde provedl 17 přidání a 2 odebrání
  1. +17
    -2
      crmEntity_test.go

+ 17
- 2
crmEntity_test.go Zobrazit soubor

@@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"log"
"testing"
"time"
)
@@ -46,6 +47,7 @@ func TestCreateDuplicate(t *testing.T) {
e.FirstName = "ff" + time.Now().Format("2006-jan-02 03:04:05")
e.LastName = "ll"
e.Password = "pp"
e.EmailAddress = "abc@gmail.com"
e.Status = "New"
e.WechatHitxyID = "someopenid"
b, _ := json.Marshal(e)
@@ -70,6 +72,7 @@ func TestCreateDuplicate(t *testing.T) {
}

func TestCrmCreateEntityServerNotFound(t *testing.T) {
return
SetupConfig()
crmSite = "https://not-exist.hitxy.org.au/" //

@@ -89,13 +92,20 @@ func TestCrmCreateEntityServerNotFound(t *testing.T) {
func TestCrmReplaceEntity(t *testing.T) {
SetupConfig()
e := crmdLead{}
e.FirstName = "ff" + time.Now().Format("2006-jan-02 03:04:05")
e.LastName = "ll"
e.FirstName = "ff1" + time.Now().Format("2006-jan-02 03:04:05")
e.LastName = "ll1"
e.Password = "pp"
e.Status = "New"
e.EmailAddress = "abc@gmail.com"
e.WechatHitxyID = "someopenid"
b, _ := json.Marshal(e)
entity, err := crmCreateEntity("Lead", b)
if err != nil {
log.Println("--------------")
log.Println(err)
log.Println("--------------")
}
AssertEqual(t, err, nil, "create record should be successful")
AssertEqual(t, isErrIndicateDuplicate(err), false, "this should not be a duplicate error")

id := entity.(crmdLead).ID
@@ -108,4 +118,9 @@ func TestCrmReplaceEntity(t *testing.T) {
AssertEqual(t, err, nil, "put should have no error")
AssertEqual(t, entity.(crmdLead).WechatHitxyID, "newid", "wechat_hitxy_id should be updated")
AssertEqual(t, entity.(crmdLead).Password, "newpass", "password should have been changed to newpass")

return
//delete
deleted, _ := crmDeleteEntity("Lead", id)
AssertEqual(t, deleted, true, "test record should have been deleted.")
}

Načítá se…
Zrušit
Uložit